window.open被瀏覽器攔截后的自定義提示效果代碼
2024-05-06 14:18:50
供稿:網友
現在越來越多的瀏覽器有攔截彈出窗口的功能。廣告彈出來給攔掉了就無所謂,要是客戶在付款時給攔掉了可就不能亂算了。
Gmail的“哎呀”算是經典,可是,前天心云給出了更帥的提示=。= 記得打開瀏覽器攔截后 測試一下,在線閱讀器里不知道代碼會不會給過濾。。代碼在下邊,其實沒什么技術含量滴。挖哈哈。。。
代碼如下:
window._open=window.open;
window.open=function(sURL,sName,sFeatures,bReplace){
if(sName==undefined){sName="_blank"};
if(sFeatures==undefined){sFeatures=""};
if(bReplace==undefined){bReplace=false};
var win=window._open(sURL,sName,sFeatures,bReplace);
if(!win){
alert('天啦!你的機器上竟然有軟件攔截彈出窗口耶,好討厭哦,人家不來了啦!快去掉嘛~~555~');
return false;
}
return true;
}
=。= 重寫window.open寫了兩天都沒有想到更好的辦法,參數要一個一個加,第四個參數,似乎只是為了不被back回去,例如:
代碼如下:
window.open("a.html","a");
window.open("b.html","a","",true);
打開的b.html是沒有后退可以按滴,MSDN有說明 。
Optional. Boolean that specifies whether the sURL creates a new entry or replaces the current entry in the window's history list. This parameter only takes effect if the sURL is loaded into the same window.
true sURL replaces the current document in the history list
false sURL creates a new entry in the history list.