The following code is an example of creating global variables from within a Javascript function:
function setValue() { window.myValue = “test”; } function getValue() { alert(window.myValue); // “test” (assuming setValue has run) }
Global Variables in JavaScript – Snook.ca.
Post Tags: Global Variables, JavaScript