Detect if the browser automatically masks pop-up windows

Source: Internet
Author: User

Now similar to Google Toolbar toolbar almost all provide pop-up blocking function, but in the actual web development work in many cases still need to automatically talk about the window, so you need to detect and remind users to disable the feature.

When using MSN WebMessenger, found that it can tell me to use the pop-up blocking function, after analyzing its code, extract the following program, you can directly use in their own projects, after testing, you can detect the Internet Explorer in Google and other tool bar blocking situation, But Gosurf and other multithreaded browser blocking pop-up page blocking is not detected, I will use a variety of browsers to do a test, add the results.

  <! doctype html public  "-//w3c//dtd html 4.0 transitional//en" > < HTML >< Head >< title > Pop-up windows Check </TITLE > < meta  http-equiv =content-type  Content = "text/html;  Charset=utf-8 "> < Script language = javascript > function  openwindow (u,n,w,h) {   & nbsp var  optionstring  =   "height="   +  h  +   ", width="   +  w  + &NB Sp ", Menubar=no,titlebar=yes,resizable=yes,scrollbars=no,status=no,toolbar=no";                               window.open (u,n,optionstring); var     spbw  =   false; function  showblockerwarning () {     return  spbw;} function  init () {      if   (true   = = &nbSp;detect ())     {        spbw  =   true; &NBSP;&NBSP;&NBSP;&NBSP}} function  detect () {     var  e  =   false;  &n bsp;   var  pw1  =   NULL;      var  pw2  =   NULL;      try     {         do          {              var  d  =   New  date ();              var  wName  =   "Ptest_"   +  d.gettime ();              var  testUrl  =  isybi ()  ?   "popuptest.aspx"  :  "";             pw1  =  window.open (Testurl,wname, "width=0,height=0,left=5000,top=5000", true);              if   (null   =  pw1  | |   true   = =  pw1.closed)             {                 e  =   true;                  break;             }              pw2  =  window.open (Testurl,wname, "width=0,height=0");              if   (null   =  pw2  | |   true   = =  pw2.closed)            &nbSp {                e  =   true;                  break;             }               if   (Isybi ())              {                  If   (pw1 !=  pw2)                  {                     e  =   true;                       break;                 }              }              Pw1.close ();             pw2.close ();             pw1  =  pw2  =   NULL; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP}          while (false); &NBSP;&NBSP;&NBSP;&NBSP}      catch (ex)     {         e  =   true; &NBSP;&NBSP;&NBSP;&NBSP}      if   (null  != &NBSP;PW1)     {          try  {  if   (! pw1.closed)  pw1.close ();  }   catch (ex) {}     }

Related Article

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.