JS window.open to determine whether the browser to open pop-up window filter function

Source: Internet
Author: User

Now many user browsers have turned on the pop-up window filtering function, indeed, pop-up windows are now generally become pop-up ads, so it is necessary to filter. However, as a developer, we should consider whether the user has turned on this feature, we will improve the program based on whether or not to open this feature, JavaScript can easily determine whether the client browser enabled window filter, the code is as follows:

The code is as follows Copy Code

<script language= "JavaScript" >
function Testopenwin (schtext) {
if (!schtext== ') {
var toolswin=window.open (Schtext, "", "");
if (toolswin==null) {
Window.alert ("has opened the window filter function!") NN to run this program correctly, temporarily turn off this feature! ") ;
}
}
}
</script>

You can use the following code to verify that the user has turned off the window filter function.

The code is as follows Copy Code

<form name= "Thisform" >
<select name= "Sitelist" onchange= Testopenwin (document.thisform.sitelist.options[ Document.thisform.sitelist.selectedindex].value) "><option value=" "Selected>= Please select =</option>< Option value= "" "> Source Enthusiasts </option><option value=" http://www.111cn.net "> Baidu search </option><option Value= "Http://qq.111cn.net" >csdn</option><option value= "http://mingzi.111cn.net" > Technology online </option >
</select>
</form>


If the above code is run, there is no prompt at the top of the browsing end, indicating that the user has banned the window filter.

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.