我在前端有一个带有不同按钮的页面,所有按钮都可以单独正常工作,但是如果我单击在chrome网站商店中打开扩展程序的按钮,然后再单击另一个按钮,则该页面不会打开。
这是我所谈论的事的典范。如果您在不关闭要打开的标签的情况下单击按钮,则在chrome网上商店打开后单击的按钮将无效。有人知道这是为什么以及如何解决吗?
https://html-ichr7r.stackblitz.io
这是它的代码。
<button id="button1" onclick="window.open('https://www.facebook.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button2" onclick="window.open('https://www.google.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
<button id="button3" onclick="window.open('https://chrome.google.com/webstore/detail/dark-mode/dmghijelimhndkbmpgbldicpogfkceaj?hl=de','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button4" onclick="window.open('https://www.9gag.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
任何帮助表示赞赏!
编辑:我刚刚发现它可以在Firefox中使用,但仍然不知道为什么它不能在Chrome中使用。
我有一个解决方案:将您的Google网络商店链接更改popup
为,例如popupWindow
,这样您将拥有:
<button id="button1" onclick="window.open('https://www.facebook.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button2" onclick="window.open('https://www.google.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
<button id="button3" onclick="window.open('https://chrome.google.com/webstore/detail/dark-mode/dmghijelimhndkbmpgbldicpogfkceaj?hl=de','popupWindow','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button4" onclick="window.open('https://www.9gag.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
使用此代码,您实际上将有两个不同的弹出窗口。
关于解释,我对此感到有些困惑。我认为Chrome浏览器正在阻止执行JShttps://chrome.google.com/webstore/*
作为一种安全措施。您可以在此处和此处阅读有关类似问题的更多信息。
加法(对此有所考虑之后):
这可能是Chrome开发人员的明智之举。通过不允许任何JS更改上的任何页面https://chrome.google.com/webstore/
,他们可以确保没有扩展程序也可以更改此页面。想象一下,如果您安装的扩展程序在广告中做得很好,那么它将获得积极的成绩,同时也会更改扩展程序网上商店的页面。它可能诱使用户安装会感染用户浏览器或计算机的其他扩展程序或软件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句