Dynamically set document.domain to iframe
I do not know if it will help but i use this in iframe
try {
var domainName = window.parent.parent.iframeData.domainName;
}
//Access violation
catch (err) {
document.domain = window.location.hostname.replace('www.', '');
}
So i check if domain already set we have exception ang try to guess domain, in either case, there is no need to set a domain
EDIT: More correctly to use post message to set domain if needed
In short, it can't. Setting document.domain
only works when the iFrame and containing window are actually part of the same domain. If a browser were to let you set document.domain
to something other than the domain you were actually on, it would be a security violation. Consider, any malicious script could just say 'No really, trust me on this one' and the browser would essentially be saying, 'Oh, okay, since you asked so nicely, here's all the permission you want'.
document.domain
can only be set to a parent domain of the actual domain of the page. If an iFrame and a containing window don't share at least that, then no browser will allow them to cross talk.
Unless I've misunderstood your question. Feel free to post some examples to clarify.