javascript - 为什么我不能在 chrome 网上商店中打开带有 html 按钮的选项卡?
问题描述
我的前端有一个带有不同按钮的页面,所有按钮本身都可以正常工作,但是如果我单击在 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/
,他们确信也没有扩展可以更改此页面。想象一下,如果您安装了一个在广告中做得很好的扩展,那么它会得到一个积极的分数,同时它也会改变扩展网络商店的页面。它可能会诱使用户安装其他(hacky/adware-ish)扩展程序或软件,从而感染用户的浏览器或计算机。
推荐阅读
- javascript - 使用来自的值填充模态
- sql - 无法在 Apex Oracle SQL/PL PLS-00103 中编译我的触发器
- git - Git是否更改了“!” .gitignore 的前缀行为?
- typescript - Electron TypeScript Parcel 第二个 BrowserWindow
- python - Python中列值的累积和循环重置每年特定月份的值
- c# - 如何选择列表框中的项目,以便列表框呈现所选项目的子数组
- php - 合并描述和附加信息。边框未延伸到内容
- python - 如何从文本文件中读取数据库凭据?
- android - 使用 android:configChanges="orientation|screenSize"/> 并且它在方向更改时弄乱了我的横向布局
- typescript - 如何隐藏函数参数缺失类型通知?