[wd_asp elements=’search’ ratio=’100%’ id=1]

Global Variables in JavaScript

25th April 2014

Javascript

javascript category codehaven

If you declare a variable outside of a function, it becomes global.
If you have problems, you can attach the variable to the window.

function dog()
{
window.myvalue = "Yay it works";
}

and check it by
alert(window.myValue);