Techniques for JavaScript to check whether pop-up windows are blocked

Source: Internet
Author: User

This article mainly introduces the JavaScript to check whether pop-up windows are blocked method tips, this article is used to detect window.open pop-up window is blocked, the need for friends can refer to the

The exit box is useful and requires a pop-up window. For programmers who develop such a site, they have a tricky problem, and they don't know if the pop-ups are blocked by browsers or various browser plug-ins, not popping out. Of course, the browser notifies the user, but these rarely cause the user's attention. Here's an easy way to test whether your pop-up window is blocked.

The JavaScript

The code is as follows:
var windowname = ' Userconsole ';
var popUp = window.open ('/popup-page.php ', Windowname, ' width=1000, height=700, left=24, top=24, scrollbars, resizable ') ;
if (popup = null | | typeof (popup) = = ' undefined ') {
Alert (' Please unblock the window and click the link again. ');
}
else {
Popup.focus ();
}
The first step is a normal pop-up window, and capture the window handle to check if the handle object exists. If there is, thank God. If it does not exist, we prompt the user to turn off the Pop-up Blocker settings and click on the link again. Of course, you can use more persuasive information to prompt the user. Or you can use a pop-up layer to display the information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.