点击导航条进入其中一个页面后,进入此页面的链接无效,我的代码是这样的,但是没有反应?
function unlink(A)
{
A=window.location.href;
var arr=document.getElementsByTagName("a");
for(var i=0;i<arr.length;i++)
{
if(A=="arr[i].href")
{
arr[i].removeAttribute("href") ;
}
}
}请高手指点一下?
function unlink(A)
{
A=window.location.href;
var arr=document.getElementsByTagName("a");
for(var i=0;i<arr.length;i++)
{
if(A=="arr[i].href")
{
arr[i].removeAttribute("href") ;
}
}
}请高手指点一下?
<script>
function unlink()
{
var A=window.location.href;
var arr=document.getElementsByTagName("a");
for(var i=0;i <arr.length;i++)
{
if(A==arr[i].href)
{
arr[i].removeAttribute("href") ;
}
}
}
</script>
<script language="javascript">
function unlink(A)
{ var arr=document.getElementsByTagName("a");
for(var i=0;i<arr.length;i++)
{
if(A=="arr[i].href")
{
arr[i].removeAttribute("href") ;
}
}
}
</script>
<div class="nav">
<div id="toplinks">
<a href="/cn/1.php" onclick=unlink("/cn/index.php")>aa</a>
<a href="/cn/2.php" onclick=unlink("/cn/Product.php")>bb</a>
<a href=="/cn/3.php">cc</a>
<a href="/cn/4.php">dd</a>
<a href="/cn/5.php" onclick=unlink("/cn/NewsList.php")>ee</a>
<a href="/cn/6.php" onclick=unlink("/cn/JoinUs.php")>ff</a>
<a href="/cn/7.php" onclick=unlink("/cn/AboutUs.php")>gg</a>
</div>通过alert打印出的A是/cn/1.php,打印出的arr[i].href是file:///cn/1.php两个路径显然不相符,但是怎样把arr[i].href中的/cn/1.php取出来呢?
<body onload='f();'>
<a id="1" href="1.html">index1</a>
<a id="2" href="2.html">index2</a>
<a id="3" href="3.html">index3</a>
</body><script>
function f(){
var url = window.location.href;
var id = url.substring(url.length-6,url.length-5); /* 设法把id拼出来 */
document.getElementById(id).removeAttribute('href');
}
</script>
对了 如果我真的想从比如说“file:///cn/i.php”路径去掉“file://” 这个怎么实现呢?