Cku*_*ner 9 html javascript google-chrome
我的前端有一个页面,有不同的按钮,所有按钮都可以完美运行,但是如果我单击在 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>
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏!
编辑:我刚刚发现它在 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>
Run Code Online (Sandbox Code Playgroud)
使用此代码,您实际上会看到两个不同的弹出窗口。
关于解释,我对此有点一无所知。我认为 Chrome 正在阻止执行 JShttps://chrome.google.com/webstore/*作为一种安全措施。您可以在此处和此处阅读有关类似问题的更多信息。
添加(经过一些思考后):
这可能是 Chrome 开发者的明智之举。通过不允许任何 JS 更改 上的任何页面https://chrome.google.com/webstore/,他们确信也没有扩展可以更改此页面。想象一下,如果您安装的扩展程序在广告中做得很好,那么它将获得积极的分数,同时它也会改变扩展程序网上商店的页面。它可能会诱骗用户安装额外的(黑客/广告软件)扩展程序或软件,从而感染用户的浏览器或计算机。