我在使用MSN Webmessenger时,发现它可以告诉我使用了弹出窗口阻挡功能,在分析代码后,提取出下面的程序,可以直接使用。
<!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){}
}
if (null != pw2)
{
try { if (!pw2.closed) pw2.close(); } catch(ex){}
}
return e;
}
function IsYBI()
{
var i = false;
try
{
var xObj = new ActiveXObject("YBIOCtrl.CompanionBHO");
if (xObj==null) i = false;
else i = true;
}
catch(ex) { i = false; }
return i;
}
Init();
</SCRIPT>
<SCRIPT language=javascript>
var warningMessage = "检查到使用了弹出窗口阻挡器!Pop-up blocker detected.";
var warningInformation = "请确保浏览器允许本网站打开弹出窗口。";
var g_blockerHtml;
g_blockerHtml = "<div><table border=1 cellspacing=0 cellpadding=0>";
g_blockerHtml += "<tr><td>" + warningMessage + "</td></tr>";
g_blockerHtml += "<tr><td>" + warningInformation + "</td></tr>";
g_blockerHtml += "</table></div>";
</SCRIPT>
<SCRIPT language=javascript>
var messengerWindow = null;
function OnLoad_WelcomePage()
{
if ( ShowBlockerWarning() )
{
var messageObject = document.getElementById("noPopHtml");
if (null != messageObject)
{
messageObject.innerHTML = g_blockerHtml;
}
}
}
</SCRIPT>
</HEAD>
<BODY onload=OnLoad_WelcomePage();>
<SPAN id=noPopHtml>
</BODY>
</HTML>