views:

607

answers:

1

The Same Origin Policy Documentation says this:

There is one exception to the same origin rule. A script can set the value of document.domain to a suffix of the current domain. If it does so, the shorter domain is used for subsequent origin checks. For example, assume a script in the document at http://store.company.com/dir/other.html executes the following statement:

document.domain = "company.com";

After that statement executes, the page would pass the origin check with http://company.com/dir/page.html. However, by the same reasoning, company.com could not set document.domain to othercompany.com.

Do all popular browsers support this? If not, which ones don't?

+6  A: 

Firefox 2,3, IE6,7,8, Chrome, and Safari 2 and 3, Opera 9 all support document.domain;

Other "newer" browsers likely will as well, however those are the ones that I've actually tested my code (which makes use of document.domain)

Alan
How about Opera?
altCognito
Opera 9 does as well.
Alan
@Alan: Thanks for the info. If you can share, what was your reason for doing so? I'm interested in making it easier to make AJAX-type requests to different machines, but I'm curious if there are other uses.
Jacob Gabrielson