Avoid browser popup blockers(避免浏览器弹出窗口拦截器)
问题描述
我正在开发一个纯 JavaScript 的 OAuth 身份验证流程,我想在弹出窗口中向用户显示授予访问权限"窗口,但它被阻止了.
I'm developing an OAuth authentication flow purely in JavaScript and I want to show the user the "grant access" window in a popup, but it gets blocked.
如何防止由 window.open
或 window.showModalDialog
创建的弹出窗口被不同浏览器的弹出窗口阻止程序阻止?
How can I prevent pop up windows created by either window.open
or window.showModalDialog
from being blocked by the different browsers' pop-up blockers?
推荐答案
一般规则是,如果 window.open
或类似的内容是从 直接用户操作.也就是说,您可以调用 window.open
来响应按钮单击而不会被弹出窗口阻止程序击中,但是如果您将相同的代码放入计时器事件中,它将被阻止.调用链的深度也是一个因素 - 一些较旧的浏览器只查看直接调用者,较新的浏览器可以回溯一点以查看调用者的调用者是否是鼠标点击等.保持尽可能浅以避免弹出窗口阻止程序.
The general rule is that popup blockers will engage if window.open
or similar is invoked from javascript that is not invoked by direct user action. That is, you can call window.open
in response to a button click without getting hit by the popup blocker, but if you put the same code in a timer event it will be blocked. Depth of call chain is also a factor - some older browsers only look at the immediate caller, newer browsers can backtrack a little to see if the caller's caller was a mouse click etc. Keep it as shallow as you can to avoid the popup blockers.
这篇关于避免浏览器弹出窗口拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:避免浏览器弹出窗口拦截器


基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01