Monday, March 30, 2009
This is an imitation of PHP $_GET, in pure Javascript.
From http://www.11tmr.com/11tmr.nsf/D6Plinks/MWHE-695L9Z
function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 )
{
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return unescape(strReturn);
}
Labels: Javascript, Web Programming
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment