简体   繁体   English

您如何检测Chrome中是否阻止了弹出到另一个域的弹出窗口?

[英]How do you detect if a popup to another domain was blocked in Chrome?

You can detect whether a popup has been blocked in Chrome with the solutions to this question: Detect blocked popup in Chrome 您可以使用以下问题的解决方案来检测 Chrome中是否已阻止弹出窗口检测Chrome中被阻止的弹出窗口

However, the solutions seem to be detect is a popup for a page that is on the same domain. 但是,似乎可以检测到该解决方案是位于同一域上的页面的弹出窗口。 I was wondering if there was a way to detect if the popup for page on another domain was blocked? 我想知道是否有一种方法可以检测另一个域上的页面弹出窗口是否被阻止?

var newWindow = window.open('http://www.google.com/'); // this domain is something.com
if (newWindow) {
    setTimeout(function() {
        // Is there a way to detect if newWindow was blocked?
    }, 500);
}

You'll be bound by all the usual same origin policies, and I'd recommend reading up on them directly: http://en.wikipedia.org/wiki/Same_origin_policy . 您将受到所有相同的原产地政策的约束,我建议您直接阅读它们: http : //en.wikipedia.org/wiki/Same_origin_policy In short, you're trying to do cross-domain communication, which is prohibited by the browser's security model. 简而言之,您正在尝试进行跨域通信,这是浏览器的安全模型所禁止的。 To get around it, there are server-side proxies, JSONP, Flash, document.domain (but only if it's two different subdomains), and a bevy of hacks that work with varying success depending on your support requirements and what exactly you're trying to do. 为了解决这个问题,有服务器端代理,JSONP,Flash,document.domain(但仅当这是两个不同的子域时),并且有一系列黑客根据您的支持要求和您的实际需求而取得不同的成功试图做。

Can you tell us more about what your browser support requirements are? 您能否告诉我们更多有关您的浏览器支持要求的信息? Can you use XHR Level 2? 您可以使用XHR Level 2吗? What's the page you're trying to load in the popup? 您要在弹出窗口中加载的页面是什么?

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

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