浏览主站 | 站长工具 | 新闻资讯 | 站长学院 | 站长盈利 | HTML教程 | 网址导航 | 站长周刊 | 会员投稿 | 滚动新闻 | RSS
发新话题
打印

[Web开发] 百分百弹窗

百分百弹窗

出处:蓝色理想
优点:兼容性很好,而且俺觉得不应该有什么拦截工具可以拦截下来
优点:代码非常短
缺点:必须在页面点击后才会弹出


<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"  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>

TOP

说明:

1.为了保证页面中的 img 不会出现丑陋的边框
<style>
#link001 img { border-style:none; }
</style>

TOP

2.保证窗口只弹出一次
<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>
3.这个结构是弹窗的根本---其实只不过是个 target="_blank" 的链接而已,拦截程序要是连这个都要拦,俺也无话可说
<body>
<a href="http://www.im286.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>

TOP

看不明白是什么意思 楼主给点注解就好了

TOP

发新话题