[Javascript] IE onclick problem

Cutter (JSRelated) java.script at cutterscrossing.com
Wed Apr 16 20:22:03 CDT 2008


That's the point, in this case/usage you don't.

Here's what I mean. It's exactly like doing form validation. You have a 
form.submit() event, which you override in some way by saying "do all of 
this. Oh wait, that failed, so we have to stop." Your validation methods 
return false to the submit method itself, stopping it from performing 
it's default 'submit' action. Or, your validation methods all return 
true, ultimately passing that to the 'submit' event, allowing it to 
complete it's default action. The 'click' handler works the same way. By 
specifying 'true' or 'false' in your onclick attribute, you are just 
telling the click event whether it should do it's default 'click' 
action, or just stop right there. Any logic/process/programmatic magic 
you are doing (or want to do) should happen, then return a true or false 
to the click handler so that it knows to stop or continue.

This is why I started using JQuery. Makes these things really simple.

Steve "Cutter" Blades
Adobe Certified Professional
Advanced Macromedia ColdFusion MX 7 Developer
_____________________________
http://blog.cutterscrossing.com

Troy III Ajnej wrote:
> Yes,
> but how do you hadle it, -how do you capture the bolean response
> of true or false in case it fails to run, or in casse it succeeded, how
> do you check it prior to invoking other instuctions?
>  
>  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                        Troy III
>                            progressive art enterprise
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
>  > From: david at dorward.me.uk
>  > To: javascript at lists.evolt.org
>  > Date: Wed, 16 Apr 2008 09:46:42 +0100
>  > Subject: Re: [Javascript] IE onclick problem
>  >
>  >
>  > 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/
>  >
>  >
>  > _______________________________________________
>  > Javascript mailing list
>  > Javascript at lists.evolt.org
>  > http://lists.evolt.org/mailman/listinfo/javascript
> 
> 
> ------------------------------------------------------------------------
> Get in touch in an instant. Get Windows Live Messenger now. 
> <http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_getintouch_042008>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript




More information about the Javascript mailing list