• Page 1 of 1
  • 1
uCoz Community » For Webmasters » Site Promotion » Cross-domain website promotion (The problem is the same origin policy.)
Cross-domain website promotion
eyesfit007
Posts: 3
Reputation: 0

Message # 1 | 7:49 AM
I'd like to offer a way to my users to promote my website, blog etc. on their website. I can make a banner, logo whatever that they can embed to their site, but I'd like to offer dynamic content, like "the 5 newest entry's title from my blog".

The problem is the same origin policy. I know there is a solution (and I use it): they embed a simple div and a JavaScript file. The JS makes an XmlHttpRequest to my server and gets the data as JSONP, parses the data and inserts into the div.

But is it the only way? Isn't there a better way I could do this? On the Internet there are tons of widget (or whatever, I don't know how they call...) that gain the data from another domain. How they do that?
Post edited by eyesfit007 - Wednesday, 2020-02-05, 7:49 AM
joexyz
JOE-vascript
Posts: 1770
Reputation: 78

Message # 2 | 3:29 PM
eyesfit007, you can use informers for this. Create an informer with your latest posts and then use the following URL:
Code
http://yoursite.ucoz.com/informer/1

where yoursite.ucoz.com is the URL address of your side and 1 is the ID of the informer.

This is essentially a JavaScript file that writes the output generated by the informer to the document. Your users can promote your newest entries using the following snippet:
Code
<script src="http://yoursite.ucoz.com/informer/1"></script>

Please note that your custom CSS styles (i.e. from the website's stylesheet template) will not work on your users' websites. If you want to have custom styling, I recommend that you use the style attribute instead.

Fun fact: this is how $MYINF_n$ codes work too!

hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau

sometimes i lurk here
eyesfit007
Posts: 3
Reputation: 0

Message # 3 | 3:47 PM
Thanks @joexyz For your valuable Feedback.
Post edited by eyesfit007 - Thursday, 2020-02-06, 3:49 PM
uCoz Community » For Webmasters » Site Promotion » Cross-domain website promotion (The problem is the same origin policy.)
  • Page 1 of 1
  • 1
Search: