[Javascript] IE onclick problem

David Dorward david at dorward.me.uk
Wed Apr 16 03:46:42 CDT 2008


On 16 Apr 2008, at 08:57, Troy III Ajnej wrote:

> > <a href="#" onclick="return addPlayer();">Add Player</a>


> What does the "return" statement stand for?!! I've never used it.
> Neither did I happen to come to the situation that I would be forced
> to do so. -So, than, why is it standing there?


Assuming it is written sensibly, the addPlayer function will return  
either a true or false value depending on the success of its attempt  
to run. By capturing that value and returning it from the event  
handler, the fallback mechanism (BTW, href="#" is a link to the top of  
the page ... which is a dreadful fallback mechanism) can be allowed to  
run or be cancelled.


-- 
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/





More information about the Javascript mailing list