[Javascript] Avoid multiple onclick

Paul Novitski paul at juniperwebcraft.com
Tue Nov 7 17:41:45 CST 2006


At 11/7/2006 02:55 PM, Guillaume wrote:
>I was trying the same but with:
>
>var bInitialized = false; Wich strangely was not working.


Each time you use 'var' you are initializing a variable, which 
creates it at the current scope level if it doesn't already exist at 
that level.  A local variable is one created inside a 
function.  Therefore in this example:

var sValue = 'global';

function fnDisplayGlobal()
{
         alert(sValue);
}

function fnDisplayLocal()
{
         var sValue = 'local';
         alert(sValue);
}

... two variables are created using the same name, one at global 
scope and one at local.  Run fnDisplayGlobal() to display 'global' 
and run fnDisplayLocal() to display 'local'.

I urge you to read the JavaScript language specifications:

         Core JavaScript 1.5 Guide
         http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide

Another good resource is:

         Gecko DOM Reference
         http://www.mozilla.org/docs/dom/domref/

Regards,
Paul 




More information about the Javascript mailing list