码迷,mamicode.com
首页 > Web开发 > 详细

js取消页面超链接的方法

时间:2015-05-27 22:50:55      阅读:386      评论:0      收藏:0      [点我收藏+]

标签:js取消页面超链接的方法


 <?php
 header('content-type:text/html;charset=utf-8');
 
 ?>
 
<A href="http://www.baidu.com" >百度</A>    <A href="http://www.jb51.net" >脚本之家</A> 
<A href="http://s.jb51.net" >服务器软件</A>    <A href="http://sc.jb51.net" > 素材下载</A> 
<A href="http://tools.jb51.net" >站长查询</A>    <A href="http://www.jb51.net/jiaoben/" >脚本下载</A> 
<input type=button id=o1 value="取消所有链接" onclick="javascript:doLinkAll(false)"> 
<input type=button id=o2 value="重新设置链接" onclick="javascript:doLinkAll(true)"> 
<script> 
function doLinkAll(action){ 
var arr=document.getElementsByTagName("A") 
for(var i=0;i <arr.length;i++){ 
if (action){ //重新设置链接 
if (arr[i].rel) arr[i].setAttribute("href",arr[i].rel) 
}else{ //取消所有链接 
arr[i].setAttribute("rel",arr[i].href) 
arr[i].removeAttribute("href") 
} 
} 
o1.disabled=!action 
o2.disabled=action 
} 
</script> 



js取消页面超链接的方法

标签:js取消页面超链接的方法

原文地址:http://blog.csdn.net/phpfenghuo/article/details/46054757

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!