js阻止浏览器默认行为
js阻止浏览器默认行为
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <a id="a1" href="http://www.baidu.com">百度</a> <script> function stopDefault(e){ //非IE if(e && e.preventDefault) e.preventDefault(); //IE else window.event.returnValue = false; } window.onload = function(e){ var a1 = document.getElementById("a1"); a1.onclick = function(e){ stopDefault(e); } }; </script> </body> </html>