A
Alex Shinn
I have a site which uses popup windows as a convenience in filling out
forms - you choose some data on the popup, click OK, and it sets data on
the parent windows form. This works fine in all major browsers and
platforms.
However, on Mac IE (OS 9 or 10, all versions), there is one situation
where this fails. If the parent window was itself launched as a popup,
and the parent window's parent was from a different domain than the
popup, then a security error is triggered because IE thinks you're
trying to access data from a page in a separate domain. As a diagram:
A B C
+------------+ +---------+ +-------+
| Other Site |---| My Site |---| Popup |
+------------+ +---------+ +-------+
^ |
+------------+
Access Form Data
In the above situation we get an error in JavaScript on page C when
accessing window.opener.anyformdata, because although Mac IE should be
checking the domains between window B & C, somehow it is checking
against the unrelated domain in window A.
The obvious solution is not to launch my site as a popup, but alas that
may not be an option. Are there any ideas for workarounds? I've tried
alternate ways of accessing the parent window B other than
window.opener, but the only thing I could think of was something like
var b = window.open(x, 'B', opts)
to get a direct reference to window B (which may or may not solve the
problem), but whatever x is it will reset at least the form data in the
window.
forms - you choose some data on the popup, click OK, and it sets data on
the parent windows form. This works fine in all major browsers and
platforms.
However, on Mac IE (OS 9 or 10, all versions), there is one situation
where this fails. If the parent window was itself launched as a popup,
and the parent window's parent was from a different domain than the
popup, then a security error is triggered because IE thinks you're
trying to access data from a page in a separate domain. As a diagram:
A B C
+------------+ +---------+ +-------+
| Other Site |---| My Site |---| Popup |
+------------+ +---------+ +-------+
^ |
+------------+
Access Form Data
In the above situation we get an error in JavaScript on page C when
accessing window.opener.anyformdata, because although Mac IE should be
checking the domains between window B & C, somehow it is checking
against the unrelated domain in window A.
The obvious solution is not to launch my site as a popup, but alas that
may not be an option. Are there any ideas for workarounds? I've tried
alternate ways of accessing the parent window B other than
window.opener, but the only thing I could think of was something like
var b = window.open(x, 'B', opts)
to get a direct reference to window B (which may or may not solve the
problem), but whatever x is it will reset at least the form data in the
window.