屏蔽iframe中的超链接

来源:互联网 发布:淘宝托管公司排名杭州 编辑:程序博客网 时间:2024/05/13 18:31
在道州网daozhou.net网站设计时,碰到了一个问题,如何屏蔽iframe中的超链接?
经过摸索,屏蔽iframe中的超链接找到了一个办法,呵呵
 
步骤一:
新建一个文档,命名为A.html,代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div style="width:800px;height:200px;position:absolute;filter:alpha(opacity=0);top:0;left:0;"></div>
<iframe style="margin-top:6px;float:left;" src="http://my.daozhou.net;" width="800px" height="200px" frameborder="0" scrolling="no" allowTransparency="true"/>
</body>
</html>
 
步骤2二:
使用框架调用A.html文档:
<iframe width="800" height="200" src="a.html" frameborder="0" scrolling="no" allowTransparency="true"></iframe>
 
这样就顺利地实现了iframe无链接点击。
原理:在iframe上面覆盖一个DIV,DIV必须有背景色且透明。position为absolute,通过top和left属性控制该DIV的位置使之覆盖于iframe之上。这样iframe就被遮盖住,而里面的任何东西都点不了了。
原创粉丝点击