How to use JavaScript to check whether the pop-up window is blocked _ javascript skills

Source: Internet
Author: User
This article describes how to use JavaScript to check whether a pop-up window is blocked. whether the pop-up window is blocked or not. if you need it, you can refer to the pop-up window below. a pop-up window is required. Programmers who develop such websites have a difficult problem. they do not know whether these pop-up windows have been blocked by browsers or various browser plug-ins. Of course, the browser will notify the user, but these will rarely attract the user's attention. The following is a simple method 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 ('remove the window blocking and click the link again. ');
}
Else {
PopUp. focus ();
}


The first step is to pop up the window normally and capture the window handle to check whether the handle object exists. If so, thank God. If it does not exist, we suggest you close the pop-up window blocking settings and click the link again. Of course, you can use more convincing information to prompt users. Or you can use a pop-up layer to display 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.