Javascript in HTML: when to use semi-colons, when to return false? -


consider following examples of javascript attributes in html elements:

<input type="button" onclick="somcefunc()" /> <input type="button" onclick="somcefunc();" /> <input type="button" onclick="somcefunc(); return false;" /> 

when should 1 end somefunc() call semi-colon, , when should semi-colon eliminated? also, when should 1 end attribute call return false;?

thanks.

when should 1 end somefunc() call colon, , when should colon eliminated?

that's semi-colon. end expressions one. automatic semi-colon insertion has enough gotchas better off avoiding it.

also, when should 1 end attribute call false?

false literal, not function, can't call it.

the usage in example absolutely nothing.

if return false intrinsic event attribute (like onclick) stop default action of control firing. e.g. link not followed. button has no default action though.

intrinsic event attributes should avoided in favour of unobtrusive javascript.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -