要实现的功能:<div id="href_false" 里的链接默认失效,当触发function href_true() 以后,链接生效,可以正常点开
要求,只能在function href_true() 里写入代码,不能在<a>里写入代码,最多在div里写入代码<!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>
<script language="javascript">
<!--
function href_true() 
{
 
}
 
//-->
</script></head><body>
 
<div id="href_false"  onclick="return false;"> <a  href="http://www.baidu.com"   >www.baidu.com][csdn]csdn社区</a><div><input type="button"  onclick=href_true()  id="btn" value="接触锁定" /></body></html>

解决方案 »

  1.   

    只能在function href_true() 里写入代码,
    不能在<a>里写入代码,
    实在不行可以在div里写入代码
      

  2.   


    <!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>
            <style>
            </style>
        </head>
        <body>
    <div id="test"><a href="http://baidu.com">百度</a></div>
            <script>
    function $(o){return document.getElementById(o)}
    $('test').onclick = function(){
    window.open('http://www.google.com.hk/');
    return false;
    }
            </script>
        </body>
    </html>
    这个意思?
      

  3.   


    <!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>
            <style>
            </style>
        </head>
        <body>
    <div id="test"><a href="http://baidu.com">百度</a></div>
            <script>
    function $(o){return document.getElementById(o)}
    $('test').onclick = href_true;
    function href_true(){
    window.open('http://www.google.com.hk/');
    return false;
    }
            </script>
        </body>
    </html>变一下就可以了。
      

  4.   


    window.open('http://www.google.com.hk/');这个链接无法固定出现在代码里,你怎么捕获?
      

  5.   

    window.open('http://www.google.com.hk/');这个链接无法固定出现在代码里,你怎么捕获?
      

  6.   

    哦 ,是 点按钮 触发<!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>
    <script language="javascript">
    <!--
    function $(o){return document.getElementById(o)}
    function href_true() 
    {
     var obj = $('href_false').getElementsByTagName('a')[0]
     window.open(obj.href)
    }
     
    //-->
    </script></head><body>
     
    <div id="href_false"  onclick="return false;"> <a  href="http://www.baidu.com"   >www.baidu.com][csdn]csdn社区</a><div><input type="button"  onclick=href_true()  id="btn" value="接触锁定" /></body></html>
      

  7.   

    楼上的,你这个思路不合适你是触发函数后就会弹出那个链接而我的要求是:
    触发函数后,链接变为正常可以点击,就是和正常的链接没什么二样,而不是弹出window.open(obj.href)
    需要修改
      

  8.   

     
    function href_true() 
    {
     document.getElementById("href_false").onclick = null;
    }
     
      

  9.   

    <!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>
    <script language="javascript">
    <!--
    function $(o){return document.getElementById(o)}
    function href_true() 
    {
     $('href_false').setAttribute('onclick','');
    }
     
    //-->
    </script></head><body>
     
    <div id="href_false"  onclick="return false;"> <a  href="http://www.baidu.com"   >www.baidu.com][csdn]csdn社区</a><div><input type="button"  onclick=href_true()  id="btn" value="接触锁定" /></body></html>
      

  10.   

    样可以啦:
    <!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>
        <title>Jquery Animate</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
        <script type="text/javascript">  
            function href_true()
            {
                $("#href_false").removeAttr("onclick");   
            }
        </script>  
    </head>
      
    <body><div id="href_false" onclick="return false;" ><a href="http://www.baidu.com">www.baidu.com</a></div><input type="button"  onclick='href_true()'  id="btn" value="接触锁定" /></body>
    </html>
      

  11.   

    最简单的写法:href_false.onclick="" 就OK