檢測瀏覽器是否自動屏蔽了快顯視窗

來源:互聯網
上載者:User

現在類似Google Toolbar的工具條幾乎都提供了快顯視窗阻擋的功能,但是在實際WEB開發工作中許多情況下還是需要自動談出視窗,因此需要檢測並提醒使用者禁用該功能。

在使用MSN Webmessenger時,發現它可以告訴我使用了快顯視窗阻擋功能,在分析它的代碼後,提取出下面的程式,可以直接在自己的項目中使用,經過檢驗,確實可以檢測到IE中google等工具條的阻擋情況,但是GoSurf等多線程瀏覽器的阻擋彈出頁面阻擋卻沒有檢測出來,我將使用多種瀏覽器做一個測試,將結果加上來。

  <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > < HTML >< HEAD >< TITLE > 快顯視窗檢查 </ TITLE > < META  http-equiv =Content-Type  content ="text/html; charset=utf-8" > < SCRIPT language = javascript > function  openwindow(u,n,w,h) {      var  optionstring  =   " height= "   +  h  +   " ,width= "   +  w  +   " ,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   ==  Detect())     {         spbw  =   true ;     } } function  Detect() {      var  e  =   false ;      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)             {                 e  =   true ;                  break ;             }              if  (IsYBI())             {                  if  (pw1  !=  pw2)                 {                     e  =   true ;                      break ;                 }             }             pw1.close();             pw2.close();             pw1  =  pw2  =   null ;         }          while ( false );     }      catch (ex)     {         e  =   true ;     }      if  ( null   !=  pw1)     {          try  {  if  ( ! pw1.closed) pw1.close(); }  catch (ex){}     }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.