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
Document data
Attachments:
No attachments for this document