(1)跳转地址的值为:javascript:;
(2)event.preventDefault()
(3)event.returnValue = false; //IE678阻止浏览器默认行为
<body>
<a href="javascript:;">javascript:;阻止跳转</a>
<hr>
<a href="#" class="pa">preventDefault阻止</a>
<hr>
通过javascript:;阻止表单提交事件<br><br>
<form action="javascript:;">
<input type="text">
<input type="submit">
</form>
<hr>
通过preventDefault阻止<br><br>
<form action="#">
<input type="text">
<input type="submit">
</form>
<script>
let pa = document.querySelector('.pa');
let secondform=document.forms[1];
pa.onclick = function (event) {
if (event) {
event.preventDefault()
} else {
event = window.event;
event.returnValue = false;//IE678阻止浏览器默认行为
}
}
secondform.onsubmit=function(event){
event.preventDefault()
}
</script>
</body>