Writing this article is not to tell spam advertisers that they can pop up ads or hide pop-up windows in the background, but to remind everyone that there are still some features in the IE kernel that can bypass the ad blocking function of most browsers based on IE, and even Bypassing the browser itself, a real Internet Explorer window pops up directly. Of course, not all, some are doing better, such as Maxthon. Although a new window is opened, it still exists in Maxthon, instead of popping up an IE in the background, but TT, The World, etc. This does not work with some browsers and can be opened directly as a new IE window. Since ancient times, one thing has been suppressed, and I hope there will be a corresponding solution.
The principle is simple. The pop-up ad blocking function of most browsers blocks the window.open function. Of course, there are a few tools and software that can block the showModalDialog and showModalessDialog functions, and the showModal class function can open a modal window as long as it can run. IE completely encapsulates this function, so running window.open() in the showModal class function cannot be blocked.
So if you know this principle, you can write a few javascript yourself and use it.
1. Use showModalDialog to open a specified page
2. There is no need to have content in the specified page. You only need to execute a window.open() to open a new window.
3. After opening this window, close it in the modal window (window.close())
In this way, the window you want to open can be opened indirectly through the modal window.
Related code:
Code in the main page:
<script language=javascript>
//Open modal window
function showDialog(dialogUrl){
var sUrl = dialogUrl;
var sFeathers = "help:off;resizable:off;scroll:no;status:off";
//sUrl = sUrl
window.showModalDialog(sUrl,"",sFeathers);
}
//Open the specified URL
function openUrl(sUrl){
//modal window file address
var dialogUrl = "txdialog.htm";
//Add random parameters to force refresh, which is not required here.
dialogUrl += "?r=" + Math.random()*100000;
dialogUrl += "&url=" + sUrl;
showDialog(dialogUrl);
}
</script>
test code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>Please enter the URL of the window you want to open:
<input type="text" name="txtUrl" id="txtUrl" value=" http://senyx.cnblogs.com ">
<input type=button onclick="openUrl(txtUrl.value)" value='test'>
</body>
</html>
Put the following code in the page where the modal window is located (txdialog.htm):
<script language=javascript>
functionRequest(strName)
{
var strHref = location.href;
var intPos = strHref.indexOf("?");
var strRight = strHref.substr(intPos + 1);
var arrTmp = strRight.split("&");
for(var i = 0; i < arrTmp.length; i++)
{
var arrTemp = arrTmp[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}
var sUrl = Request("url");
//alert(sUrl);
window.open(sUrl);
window.close();
</script>
Example download:
http://fanrsh.cnblogs.com/articles/280189.html