views:

57

answers:

1

I'm using a long-polling iframe solution for a chat script. Unfortunately, this requires me to set document.domain='yourdomain.com' in the iframe and main document, because the iframe is a subdomain call.

The huge problem is...now all my other scripts that use popups and iframes are broken. They now require me to put document.domain in them too. It does fix it, but this is not an ideal solution at all. Is there another way around this problem?

+1  A: 

Hi Chris,

JavaScript has cross-domain limitations for security issues. The ideal/simple solution is in fact defining the document.domain like you are suggesting.

There are other alternative solutions like JSONP or iFrame proxying. More info here: iFrame Cross domain JavaScript calls (second link in that page doesn't work but here's a good resource iFrame proxying jQuery).

Hope this helps.

XaviEsteve