You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Show Contents List

Using objGlobal to define commonly used functions

If you want to create a JavaScript function that is reused in many places you could do something like this in your signon script:
objGlobal.Mult = function (x,y) {                  var z = x * y;                  return(z);     } objGlobal.Add  = function (x,y) {                  var z = x + y;                  return(z);     }
 
These operations define 2 functions in objGlobal named Mult and Add and the code that they contain.
Once this has been done the functions objGlobal.Add and objGlobal.Mult can be executed in other scripts like this:
var q = objGlobal.Add(222,3); alert( q.toString() ); q = objGlobal.Mult(22,33); alert( q.toString() );
which would display the results 225 and 726 respectively.
 
 
Show Contents List

  • No labels