When you open a new window with Javascript, you can read and write that window's variables:
var childWindow = window.open("some-url");
childWindow.someVariable = 42;
You can even take a reference to an object in the other window and update it later.
But, how does this work, especially considering Javascript's single thread of execution?
答案 0 :(得分:-1)
Take a look into: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
This function returns:
A reference to the newly created window. If the call failed, it will be null instead. The reference can access properties and methods of the new window provided it complies with Same-origin policy security requirements.
This is exactly the same object as window
in the opened page. It works just as a simple object. If you add a property to childWindow
it will be available on the windows of opened page. The same with function execution.