winterheat
Aug 25th 2008, 4:51 am
i think conventional usage of Javascript is to use "return false" to stop the default action, be it a form for submit, a link, or a text input field.
when nothing is returned or when true is returned, then the default action is taken.
example like on http://www.0011.com/test/test_return_false.html
however, i found that this is not so widely mentioned or documented in some books. such as in Professional Javascript by Nicholas Zakas (2005) p. 278, he recommends using
oEvent.returnValue = false; // for IE
and
oEvent.preventDefault(); // for Firefox
(i don't have a copy of Javascript Definitive Guide with me right now... so I wonder if it documents returning false and true or not).
why not just use return false or true to do that? won't that work in almost all browsers?
when nothing is returned or when true is returned, then the default action is taken.
example like on http://www.0011.com/test/test_return_false.html
however, i found that this is not so widely mentioned or documented in some books. such as in Professional Javascript by Nicholas Zakas (2005) p. 278, he recommends using
oEvent.returnValue = false; // for IE
and
oEvent.preventDefault(); // for Firefox
(i don't have a copy of Javascript Definitive Guide with me right now... so I wonder if it documents returning false and true or not).
why not just use return false or true to do that? won't that work in almost all browsers?