You can detect whether a popup has been blocked in Chrome with the solutions to this question: Detect blocked popup in Chrome
However, the solutions seem to be detect is a popup for a page tha开发者_如何学编程t 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 . 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.
Can you tell us more about what your browser support requirements are? Can you use XHR Level 2? What's the page you're trying to load in the popup?
精彩评论