<script type='text/javascript'>
  function clk(url) {
    window.open(url, '_blank');
  }...<a id='a0' href='http://www.sohu.com' onclick='clk("http://www.sina.com.cn");return false;'>
...如上的代码所示,
1 客户在左键点击<a>链接时应该是执行onclick事件,执行clk函数(因为有return false;)
2 但是当我右键点击链接,在弹出菜单左键点击'打开'时 ,打开的就是href指向的地址,
现在的问题是,在进行2操作的时候,能不能让clk函数执行,而不是打开href指向的地址。
请大家帮忙,提出一些建议!

解决方案 »

  1.   

    <html>
    <head>
    <title>测试</title>
    </head>
    <script>
      function test(){
        alert("success!");
      }
    </script>
    <body>
      <a href="http://www.baidu.com" onmouseover="test();return false;">连接百度</a>
    </body>
    </html>
      

  2.   

    <html>
    <head>
    <title>测试</title>
    </head>
    <script>
      function test(url){
        window.open(url, '_blank'); ;
      }
    </script>
    <body>
      <a href="#" onmousedown="test('http://www.baidu.com');return false;">连接百度</a>
    </body>
    </html>
      

  3.   

    <a id='a0' href='#' onclick='clk("http://www.sina.com.cn");return false;'> 
      

  4.   

    这样的话
    鼠标移上去
    会变成手状
    执行的却是onclick方法
      

  5.   

    谢谢大家的回答 ,现在是,我不想改变href的值,因为我想状态栏上面显示href的地址