Javascript URL Parser

URL Format: page.htm?name1=value1&name2=value2 . . .



Usage:

  1. Download the URL parser. [ urlparser.js | 1.3 KB ]
     
  2. Place urlparser.js in the same directory as the htm file you want to be able to parse with.
     
  3. Insert the following line in the head tag of the htm file:
    Note: do not insert any code in this script tag.
     
  4. In a separate script tag, call 'parseCallingURL(url)' to parse the url. You must pass the calling URL by using 'parent.document.URL'.
     
  5. 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.