有时链接js文件要加入参数,通过javascrip可获得这些参数值,实现如下:
<script language='javascript'>
function Getparam(paramName)
{
var url = '/js/list.js?id=3&topPid=TopSearch&bottomPid=BottomSearch';
var reg = new RegExp("(^|//?|&)"+ paramName+"=([^&]*)(//s|&|$)", "i");
if (reg.test(url))
return RegExp.$2;
else
return "";
}
alert(Getparam('bottomPid'));
</script>