如何检测浏览器是否阻止弹出窗口? [英] How can I detect if a browser is blocking a popup?

查看:160
本文介绍了如何检测浏览器是否阻止弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,我遇到一个试图弹出一个新窗口(用于用户输入或重要信息)的网页,但是弹出窗口阻止程序阻止了这种情况的发生.

Occasionally, I've come across a webpage that tries to pop open a new window (for user input, or something important), but the popup blocker prevents this from happening.

调用窗口可以使用哪些方法来确保新窗口正常启动?

What methods can the calling window use to make sure the new window launched properly?

推荐答案

如果您使用JavaScript打开弹出窗口,则可以使用以下代码:

If you use JavaScript to open the popup, you can use something like this:

var newWin = window.open(url);             

if(!newWin || newWin.closed || typeof newWin.closed=='undefined') 
{ 
    //POPUP BLOCKED
}

这篇关于如何检测浏览器是否阻止弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆