tags:

views:

22

answers:

1

I have a widget that is added to random websites. The widget needs to fill an iframe with content. I need the iframe source to be from the same domain as the website it is embedded in.

To do this I want to ask the site owners to put a file in their root folder that will be used as a proxy to my server.

My question is -how can I implement such proxy with static html/js/? file without using a server side scripting?

A: 

I'm not really clear how such a proxy would work/help either way. Are you looking for something like <base />?

The only issue with the base element is that it can't be turned off once it's turned on. If the iframe is the last thing on the page, or at least the last thing with either src or href, you could set it just above. But I'm not sure that this will allow js to access the iframe as though it were by proxy.

And again, I'm still not sure how a file on the remote server will make the iframe seem like it's on your domain. And I have serious doubts whether the site owners will extend such a favor, since doing so would allow hackers to use your site as a backdoor into their server.

I'm not sure how browsers/js policy is in terms of redirects and rewrites, but maybe you could go with something like pointing the iframe to your own server, and having that page actually go to their page, either by mod_rewrite or a redirect. Either way would be server side, so maybe that's not an option. I have heard tale of another thing that works, but have yet to see it in action... You have the site owners add a script with:

 document.domain = "yourserver.net";

And be sure to set it on your script as well. This makes them play nice, supposedly. But they may not go for that if it breaks their site for other things, unless there is someway their page can tell it's inside of an iframe and can set that property conditionally.

Good luck

Anthony
Thanks for the answer. Perhaps I was not clear. the file will reside on the server of the sites that will have the widget integrated, not on my server.
Nir
Right, I got that. I don't know how such a file would work (which is probably my own ignorance), especially client-side. Are you saying the other servers will be inclined to do this because they are using your widget on their site?
Anthony
yes, I want them to put a static file on their path that will allow the iframe to have my contnent via a src in their own domain.
Nir