谷歌浏览器不考虑 window.name

Google chrome doesn#39;t take window.name into account(谷歌浏览器不考虑 window.name)

本文介绍了谷歌浏览器不考虑 window.name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在 window.open(url,name... 中,如果已经存在同名的弹出窗口,该名称基本上会限制浏览器不要再次打开弹出窗口

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

例如页面 A 打开名为thug"的弹出窗口

For example Page A opens popup named "thug"

现在我打开一个新标签.输入 localhost/pageA ,然后看到一个弹出窗口

Now I open up a new tab . enter localhost/pageA , and get to see a popup

这是问题所在,如果我在新选项卡中再次输入 URL localhost/pageA,它将重新打开弹出窗口,而不是它应该引用了之前的弹出窗口.因为他们有相同的名字

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

请帮忙

推荐答案

Chrome 中两个选项卡中的 JS 脚本在不同的上下文中运行,因此无法共享打开哪个窗口的信息.此行为是一项安全功能,我相信 Google 会在此处更好地解释它.

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.

根据您的应用所需的防弹级别,您应该使用 AJAX、cookie 甚至持久存储来检查该窗口的存在和状态.

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.

这篇关于谷歌浏览器不考虑 window.name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:谷歌浏览器不考虑 window.name

基础教程推荐