Javascript doesn't have a direct way to grab a particular url parameter. I found a couple of different url javascript methods for doing it, but they were simply wrong. I don't know what the big deal is. Here's a simple function for doing it:


function getUrlParam(name){
var href = window.location.href;

var pIx = href.indexOf('&'+ name +'=');
if(pIx < 0)
pIx = href.indexOf('?'+ name +'=');
if(pIx < 0)
return null;

var pIx2 = href.indexOf('&',pIx+1);
if(pIx2 < 0)
return href.substring(pIx+name.length+2);
else
return href.substring(pIx+name.length+2,pIx2);
}

Version 5.1 last modified by Geoff Fortytwo on 11/07/2010 at 19:18

Attachments 0

No attachments for this document
Website Top
Send Me Mail!:
   g42website4 AT g42.org
My Encyclopaedia Blog

Creator: Geoff Fortytwo on 2008/05/12 01:18
Copyright 2004-2007 (c) XPertNet and Contributing Authors
1.3.2.9174