0
「返回False」似乎只工作在內聯,而不是在文檔中。Javascript返回False在html中的作用,而不是頭
這工作:
<html><body><form action="index.html" method="post">
<input type="submit" onClick="alert('Hello'); return false;">
</form>
</body></html>
這不起作用:
<html><head>
function myfunction(){
alert("Hello");
return false;
}
</head>
<body>
<form action="index.html" method="post">
<input type="submit" onClick="myfunction();">
</form>
</body></html>
您還沒有發佈什麼作品? –
這是爲什麼令人驚訝?在第一種情況下,您將從事件處理程序返回某些內容,在第二種情況下,您不會。你從'myfunction'返回,而不是從事件處理程序返回。 –