[Javascript] Avoid multiple onclick
John Warner
john at jwarner.com
Tue Nov 7 16:36:35 CST 2006
function DoSomethingElse()
> {
> // Need to re-enable the function
> above to run again
>
> ...
bInitialized = false; // <<<-------------
> }
>
John Warner
> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Guillaume
> Sent: Tuesday, November 07, 2006 2:07 PM
> To: [JavaScript List]
> Subject: Re: [Javascript] Avoid multiple onclick
>
>
> Paul,
>
> This is perfectly working... This function will work once
> only... However how do I allow that function to run again
> once another function
> has been called ?
>
> var bInitialized = false;
> ...
> function DoSomething()
> {
> if (bInitialized) return;
> bInitialized = true;
>
> ...
> }
>
>
> function DoSomethingElse()
> {
> // Need to re-enable the function
> above to run again
>
> ...
> }
>
>
> > At 10/18/2006 01:59 AM, Guillaume wrote:
> >
> >> So what I'd like is the functions to fire only once even if onclick
> >> is performed multiple times.
> >
> >
> >
> > One method of preventing a function from running more than
> once is to
> > set a global variable the first time the function is called, and
> > refuse to run if that variable is set:
> >
> > var bInitialized = false;
> > ...
> > function DoSomething()
> > {
> > if (bInitialized) return;
> > bInitialized = true;
> >
> > ...
> > }
> >
> > Regards,
> > Paul
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
More information about the Javascript
mailing list