10-01
21

百分百弹窗(不会被拦截工具给拦截)

KingCMS官方网站 蓝色理想 hutia 2006-9-24 21:50:13 优点:兼容性很好,而且俺觉得不应该有什么拦截工具可以拦截下来
优点:代码非常短
缺点:必须在页面点击后才会弹出

<head>
<style>
#link001 img { border-style:none; }
</style>
<script>
function cancelOpenNew(){
if(!window.event){setTimeout(cancelOpenNewA,1000);return;}
var obj=window.event.srcElement;
if(!obj)return;
if(!obj.tagName)return;
if(String(obj.tagName).match(/input|select|option|textarea/i))return;
setTimeout(cancelOpenNewA,1000);
}

function cancelOpenNewA(){document.body.appendChild(document.getElementById('MainDiv001'));}
</script>
</head>
<body>
<a href="http://www.blueidea.com" target="_blank" onclick="cancelOpenNew();" id="link001" style="color:black; text-decoration:none; cursor:default; display:block;" hidefocus="true">
<div id="MainDiv001">



<!-- This is a comment -->
This is a test. <br>
I try to put something here.<br>
<input />
<br>
<div >
This is a div.
</div>
<ol>
<li><img src="http://www.blueidea.com/articleimg/bbsimg/closedb.gif"/> And this</li>
<li><img src="http://www.blueidea.com/articleimg/bbsimg/closed.gif"/> is a list</li>
</ol>

<form>
This is a Form.
<input /><input type="checkbox" />
<input type="radio" name="hutia" value="1" /><input type="radio" name="hutia" value="0" />
<select><option>This is a select</option>
<option>This is a select</option>
</select>
<textarea> And here is a textarea</textarea>
<input type="button" value="button" />
<input type="submit" value="submit" />
<input type="reset" value="reset" />
</form>

<iframe src="http://www.blueidea.com"></iframe>
<!-- This is another comment -->


</div>
</a>
</body>


说明:

1.为了保证页面中的 img 不会出现丑陋的边框

<style>
#link001 img { border-style:none; }
</style>

2.保证窗口只弹出一次




3.这个结构是弹窗的根本---其实只不过是个 target="_blank" 的链接而已,拦截程序要是连这个都要拦,俺也无话可说

<body>
<a href="http://www.blueidea.com" target="_blank" onclick="cancelOpenNew();" id="link001" style="color:black; text-decoration:none; cursor:default; display:block;" hidefocus="true">
<div id="MainDiv001">

4.千万不要忘记在页面结束的地方加上:




</div>
</a>
</body>



<script>
function cancelOpenNew(){
if(!window.event){setTimeout(cancelOpenNewA,1000);return;}
var obj=window.event.srcElement;
if(!obj)return;
if(!obj.tagName)return;
if(String(obj.tagName).match(/input|select|option|textarea/i))return;
setTimeout(cancelOpenNewA,1000);
}

function cancelOpenNewA(){document.body.appendChild(document.getElementById('MainDiv001'));}
</script>



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: 弹窗
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.