6

Prerequisites:

The browser keeps the domain as a pair ('domain','port') and setting document.domain to its own value (or any other correct one) causes the setter to overwrite port number with null (ok, WTF!?)

See: What does document.domain = document.domain do?

Question:

Is it possible to invoke the setter in a way that preserves the port or allows one to set it?

Community
  • 1
  • 1
naugtur
  • 16,827
  • 5
  • 70
  • 113
  • 1
    not in a robust way AFAIK since this is highly dependent on the specific browser/version/implementation... see for example the restrictions Mozilla imposes - https://developer.mozilla.org/en/DOM/document.domain – Yahia Nov 03 '11 at 09:38

1 Answers1

4

No.

If you never set the document.domain it's "special" it knows its never been set, and also includes the port.

Once you set it it's just a simple string, no port, and will only match other frames that have that same string.

A never set document.domain will NOT match a document.domain that was set - even if both look like they are exactly the same thing. It has nothing to do with the port. A changed document.domain will never match one that was not changed, even if it was changed to "itself".

Ariel
  • 25,995
  • 5
  • 59
  • 69
  • This is all I know, I just hoped for some weird quirks allowing that. Like the fact that in browsers that render it a .hta document hasn't got some of the cross-domain restrictions. – naugtur Nov 04 '11 at 12:14