Forum Moderators: open

Message Too Old, No Replies

different approachto call a method

         

kadnan

7:39 am on Oct 1, 2005 (gmt 0)

10+ Year Member



Hi

i have found and used different approach to call a method on some Event

for instance

<input type=text onClick=javascript:myFunc()>
Or
<input type=text onClick=myFunc()>
or
<input type=text onClick="return myFunc()">

is there any Difference in it

Bernard Marx

8:36 am on Oct 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) That one's a bit pointless (unless, perhaps VBScript is also being used - I dunno), and possibly "harmful"
[gazingus.org...]

2) Fine. (Might as well get into the habit of quoting your attribute values though)

3) This can be useful, on certain elements. If the function returns

false
, the default click action will not be executed. For instance:

function something()
{
return Math.random() > 0.5;
}

-----------

<a href="example.htm" onclick="return something();">
This link will only take you somewhere sometimes</a>