问题
I've know that in window.open(url,name... the name basically restricts a browser not to open a popup again , if a popup with the name already exists
For example Page A opens popup named "thug"
Now I open up a new tab . enter localhost/pageA , and get to see a popup
Here is the problem , if i enter the URL localhost/pageA again in a new tab , it'll REOPEN the popup , rather it should have had referenced the earlier popup. because they have the same name
Please help
回答1:
The JS scripts in two tabs in Chrome are ran in separated contexts and cannot thus share the information on which windows did one open, one to another. This behavior is a security feature and I believe it is better explained by Google, over here.
Depending on the level of bulletproofing required by your app, you should use either AJAX, cookies and even persistent storage to check for that window's existence and state.
来源:https://stackoverflow.com/questions/10259887/google-chrome-doesnt-take-window-name-into-account