简体   繁体   English

setTimeout 内的 window.open 不执行操作

[英]window.open within setTimeout doesn't perform the action

Why does this call to setTimeout show the alert box but does not do the call to window.open?为什么调用 setTimeout 会显示警告框,但不会调用 window.open? If I remove the alert, it doesn't do the window.open either.如果我删除警报,它也不会执行 window.open。

    // Pause first then open window
    function pause_first (url) {
        alert (url);
        var external_window = window.open(url,'_blank'); 
        external_window.focus();
    }

    var pause_ret = setTimeout( function() { pause_first(url); }, 1000);

Most likely, because your browser considers it to be a non-user-triggered popup … so it blocks it.最有可能的是,因为您的浏览器认为它是一个非用户触发的弹出窗口……所以它阻止了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM