/    Sign up×
Community /Pin to ProfileBookmark

Cross-domain website promotion

I’d like to offer a way to my users to promote my website([cool font at fontvilla](https://fontvilla.com/cool-font-generator/)), 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?

to post a comment
SEO

1 Comments(s)

Copy linkTweet thisAlerts:
@johncarryJun 11.2021 — If you go the JSONP route, you will implicitly ask your users to trust you, as they will give you full access to the resources of their page (content, cookies,...). If they know that they main complain.

While if you go the iframe route there is no problems.

One famous example today of embeddable content by iframe is the Like button of facebook.

And making that server side with a proxy or other methods would be much more complex, as there are plenty of environments out there. I don't know other ways.
×

Success!

Help @MehwishYati spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...