简体   繁体   中英

Difference between onsubmit=“return false” and onsubmit=“javascript:return false”

What is the diference between

onsubmit="javascript:return false"

and

onsubmit="return false"

?

The first example starts with a label (to which a break or continue statement could be linked). This is pointless as there is no loop in the function to apply the label to and no break or continue statement.

It is probably there due to cargo culting from people who are copy/pasting javascript: scheme URIs from href attributes.


Consider making your JavaScript Unobtrusive and binding your event handlers with JS instead of HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM