Home: WYSIWYG Forums: WYSIWYG Editor Discussion:
Same Origin Policy problem across subdomains

New User

Mar 18, 2005, 6:25 AM

Views: 48429
Same Origin Policy problem across subdomains

Suppose I want to generate a page in PHP that contains a htmlarea editor. Easy enough. Now suppose i have a site that for performance reasons requires static content to be served from a separate server to the PHP content (the "static" server wont be running PHP, and the PHP server shouldn't serve any images/javascript or we'll loose the performance edge that we gained by splitting the content up.) It still seems relatively easy at this point just to shift htmlarea's folder over to the static content server, and point to it from the generated PHP page. So far so good. Except that when using anything in the editor that requires a popup window, it wont be able to access the original editor because of the Same Origin Policy within javascript.

Now, Mozilla.org very kindly tells us how to get around this if the 2 servers are subdomains of the same domain name - you insert the line document.domain = "mydomain.com", and thus allow script from www1.mydomain.com and www2.mydomain.com to access each others properties.

Problem is, with that line added in my page (the generated PHP page), the editor never finishes loading. I've tried relocating the document.domain line to just about every one of the JS files (and all at the same time), and various locations on the calling page, all to no avail.

Has anyone else had this problem, or better still - a solution?



(This post was edited by billgates on Mar 18, 2005, 6:40 AM)