防止浏览器中出现窗口弹出警告 [英] Prevent window popup warning in browser

查看:87
本文介绍了防止浏览器中出现窗口弹出警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新窗口中打开一个jsp页面.使用javascript window.open会产生浏览器警告,并且在某些情况下(firefox)默认情况下会阻止弹出窗口.有什么办法解决(这不是恶意应用程序,而是内部用户工具)?

I'm trying to open a jsp page in a new window. Using javascript window.open yeilds browser warnings and in some cases (firefox) will block the popup by default. Is there any way around this (this isn't a malicious application - its an internal user tool)?

推荐答案

如果弹出窗口是由用户操作(例如单击按钮)触发的,则大多数浏览器都不会阻止该弹出窗口.例如,如果您的window.open javascript附加到按钮的onclick事件,浏览器将不会阻止它.

Most browsers will not block a popup if it is triggered by user action, such as clicking a button. For example, if your window.open javascript is attached to a button's onclick event, browsers will not block it.

另一方面,如果您尝试显示弹出窗口而没有任何用户操作,则表示您不走运.这正是烦人的广告所使用的技术,因此浏览器无法区分您的应用程序与烦人的广告.

On the other hand, if you're trying to display a popup without any user action, you're out of luck. That's exactly the technique that annoying advertisements use, so browsers can't distinguish between your app from annoying ads.

这篇关于防止浏览器中出现窗口弹出警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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