日期:2014-05-16 浏览次数:20311 次
<a id="a" href="http://www.sohu.com">aa</a> <script type="text/javascript"> var el = document.getElementById('a'); el.onclick = function(e){ alert('1'); e = e || window.event; if(e.preventDefault){ // w3c e.preventDefault(); } else { // ie e.returnValue = false; } } </script>
------解决方案--------------------
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <a href="http://baidu.com" id="test">123</a> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } $('test').onclick = function(){ this.href = 'javascript://'; } </script> </body> </html>
------解决方案--------------------
onclick="not_jump();return false;"
------解决方案--------------------
href="javascript:void(0)";或者not_jump()方法后面添加个renturn false