Javascript URL Parser
URL Format:
page.htm?name1=value1&name2=value2 . . .
Usage:
- Download the URL parser. [ urlparser.js | 1.3 KB ]
- Place urlparser.js in the same directory as the htm file you want to be
able to parse with.
- Insert the following line in the head tag of the htm file:
Note: do not insert any code in this script tag.
- In a separate script tag, call 'parseCallingURL(url)' to parse the url.
You must pass the calling URL by using 'parent.document.URL'.
- To access the variable names use the following methods:
- getMaxVars() - returns the number of variables in the url.
- getNameArray() - returns a string array of the variable names.
- getValueArray() - return a string array of the variable values.
- getVarString() - return a string of the url portion after '?'
Tip: when you open urlparser.js, JavaScript Editor automatically lists all the available functions so you can instantly navigate to any of them.