js取消页面超链接的方法
2018-07-20 来源:open-open
<?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>
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐