标签:fun efault method col asc href back 鼠标 value
p 140
//阻止默认行为(提交转跳)
1. //return false;
2. //evt.preventDefault();
3. //evt.returnValue=false;
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <form action="获取鼠标位置.html" method="get"> <a href="事件委托.html">aa</a><br /> <input type="text" /> <input type="submit" value="提交" /> </form> </body> <script type="text/javascript"> var oLink = document.getElementsByTagName("a")[0]; var oForm = document.getElementsByTagName("form")[0]; var oInput = document.getElementsByTagName("input"); oLink.onclick=function(e){ var evt = e || event; console.log("a"); //阻止默认行为(超链接) //return false; //evt.preventDefault(); evt.returnValue=false; } oForm.onsubmit=function(e){ var evt = e || event; console.log("b"); //阻止默认行为(提交转跳) //return false; //evt.preventDefault(); evt.returnValue=false; } document.oncontextmenu=function(e){ var evt = e || event; console.log("b"); //阻止默认行为(鼠标右键) //return false; //evt.preventDefault(); evt.returnValue=false; } </script> </html>
标签:fun efault method col asc href back 鼠标 value
原文地址:https://www.cnblogs.com/chengzizhou/p/12669602.html