chrome下window.open问题?

需要实现的功能:点击网页任何地方,包括链接,弹出一次窗口。
直接上代码:

<a href="1.html" target="_blank">1.html</a>&nbsp;&nbsp;
<a href="2.html" target="_blank">2.html</a>&nbsp;&nbsp;
<a href="3.html" target="_blank">3.html</a>
<script type="text/javascript">
    openflag = false;
    document.onclick = function (e) {
        if(!openflag) {
            window.open('//sohu.com');
            openflag = true;
        }
    }
</script>

问题:在IE Safari上没问题,能打开1.html 2.html 3.html和弹窗;
在chrome下诡异了,弹窗能出来,1.html 2.html 3.html却被拦截了,实在不解,求解答
<a href="1.html">1.html</a>
去掉target="_blank"没问题

chrome版本 79.0.3945.88(正式版本) (64 位)

设置了chrome的弹出窗口和重定向后,链接正常,弹窗也可以弹出
chrome为啥不拦截window.open反而拦截链接a?target="_blank"

阅读 2.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题