Home > Web Front-end > JS Tutorial > body text

JavaScript methods and techniques to check whether pop-up windows are blocked_javascript techniques

WBOY
Release: 2016-05-16 16:09:53
Original
1047 people have browsed it

The pop-up window is very useful when a pop-up window is needed. For programmers who develop such websites, they have a thorny problem. They don't know whether these pop-up windows are blocked by the browser or various browser plug-ins and do not pop up. Of course, the browser will notify the user, but these rarely attract the user's attention. Here's a simple way to test whether your pop-ups are blocked.

The JavaScript

Copy code 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 to pop up the window normally and capture the window handle to check whether this handle object exists. If it exists, thank God. If it does not exist, we prompt the user to turn off pop-up blocking settings and click the link again. Of course, you can prompt users with more convincing information. Or you can use a popup layer to display information.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!