'window.open' 被 Firefox 阻止

2022-01-20 00:00:00 google-chrome firefox popup javascript

我使用 window.open 并在文档 ready 事件中调用它,但它被 Firefox 中的弹出窗口阻止程序阻止.然后我将它添加到函数中并从按钮调用此函数,然后触发按钮单击但没有成功:

I use window.open and call it at the document ready event, but it is blocked by a popup blocker in Firefox. Then I added this to the function and make a call of this function from a button and then trigger the button click without success:

$(function(){    
    abcd();    
});


function abcd(){
    var popup = window.open("http://localhost/johndyer-mediaelement-7ed6c51/demo/index.php","mypopup","width=500,height=300");       
 }

有没有办法在页面加载时在浏览器上打开外部弹出窗口或新标签页?

Is there some way to open an external popup window or new tab on browser when the page loaded?

推荐答案

不要打开弹窗广告.很烦人.

Don't open pop up advertising. It's annoying.

另一方面,如果它是用户想要看到的消息,那么您可以使用 jQuery 插件,如 Colorbox 以显示悬停模式窗口而不打开新的弹出窗口,用户可以轻松关闭.

On the other hand, if it's a message the user wants to see, then you can use a jQuery plugin like Colorbox to display a hovering modal window without opening a new popup, that the user can easily close.

相关文章