问题
I'm trying to open a popup from window a
at example.com. then close window a
and open another window b
at the same domain (example.com). Is it possible to access the DOM of window a
from window b
and how?
The popup is opened from window a
by
window.open('http://example.com/blah', 'somename', settings..),
Executing the same from window b
with a different url (shown below) works
window.open("http://example.com/blah2", "somename" ...)
This seems to suggest windows are accessed by window name. But I could not find any way to access to DOM of the popup with or without the window's name. How would I do this?
回答1:
Try something like
var newWind = window.open('http://example.com/blah', 'somename',settings);
if (newWind.opener == null) {
newWind.opener = window;
}
// here you can access DOM of new window
var newDoc = newWind.document;
来源:https://stackoverflow.com/questions/1550600/cross-window-js-interaction-between-a-popup-and-another-window-of-the-same-domai