who can use js get url's parameter
Posted: Mon Aug 20, 2007 2:01 pm
an url like this:http://www.example.com/1.html?para1=ddd¶2=ccc
use js to get the values..
how to????
use js to get the values..
how to????
SolusVM VPS management, cPanel/WHM/Fantastico, webdesigning help and discussion forums. Get help from co-webmasters and professionals!
https://smokyhosts.com/forums/
Code: Select all
<script language="JavaScript" type="text/javascript">
function getParam(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("=") > -1 )
{
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return strReturn;
}
</script>
Code: Select all
getParam('parameter')