Skip Navigation | Home | Code Samples | Articles | Links | About | Contact Me | Make a Payment

URL Object

Access the variables in the url object in two ways

To initialize the url object, just include the following 8 lines of code within a <script> block in the head of your document.

var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++)
{
  eq = nv[i].indexOf('=');
  url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
}

Alternatively, you can download an external JavaScript file and include it in your HTML document like this:.

<script language="JavaScript" type="text/javascript">
<!-- 
  var url = new Object();
// -->
</script>
<script language="JavaScript" type="text/javascript" src="{path to file}url.js"></script>