Content deleted Content added
→Variables: And as far as I know, I was the first to invent this technique. :) |
|||
Line 7:
Variables declared outside of any function, and variables declared without the <code>var</code> statement, are in "global" scope, visible in the entire web page; variables declared inside a function with the <code>var</code> statement are local to that function.
To pass variables from one page to another, a developer can set a [[HTTP cookie|cookie]]
A third way to pass variables between pages is to include them in the call for the next page. The list of arguments, called the query string, is preceded by a question mark, and each argument specification follows the format: ''name=value''. The ampersand character is used as the list separator character. An example of this technique is ''<code>sample.html?arg1=foo&arg2=bar</code>''. The following page can then extract these values by performing [[regular expression]] operations on the <code>window.___location</code> property.
There is also an old [[hack]] that still works on most browsers: the '''window.name''' property can be set to string data which can then be retrieved by the next page to load into the window.
|