js阻止瀏覽器默認行為的簡單實例
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <a id="a1" >百度</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>以上這篇js阻止瀏覽器默認行為的簡單實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。
新聞熱點
疑難解答