location.search在客户端获取Url参数的方法
location.search是从当前URL的?号开始的字符串
如:http://www.baidu.com/s?wd=baidu&cl=3
它的search就是?wd=baidu&cl=3
如: location.search.substr(1).split("&")[0]
可以返回第一个参数:wd=baidu
如: location.search.split('?')[1]
可以返回所有参数:wd=baidu&cl=3
<script type="text/javascript">
var url = "";
if ( this.frameElement )
{
var url = this.frameElement.contentWindow.location.search;
}
else
{
var url = location.search.substring(1);
}
url = url.substring(url.indexOf("prn=")+4);
url = url.replace(",,","?");
document.write('<img src="'+url+'" alt=""/>')
</script>
var url = "";
if ( this.frameElement )
{
var url = this.frameElement.contentWindow.location.search;
}
else
{
var url = location.search.substring(1);
}
url = url.substring(url.indexOf("prn=")+4);
url = url.replace(",,","?");
document.write('<img src="'+url+'" alt=""/>')
</script>
// #### URLParams: holds all URL passed parameters (like ?Param1=Value1&Param2=Value2)
var FCKURLParams = new Object() ;
(function()
{
var aParams = document.location.search.substr(1).split('&') ;
for ( var i = 0 ; i < aParams.length ; i++ )
{
var aParam = aParams[i].split('=') ;
var sParamName = decodeURIComponent( aParam[0] ) ;
var sParamValue = decodeURIComponent( aParam[1] ) ;
FCKURLParams[ sParamName ] = sParamValue ;
}
})();
var FCKURLParams = new Object() ;
(function()
{
var aParams = document.location.search.substr(1).split('&') ;
for ( var i = 0 ; i < aParams.length ; i++ )
{
var aParam = aParams[i].split('=') ;
var sParamName = decodeURIComponent( aParam[0] ) ;
var sParamValue = decodeURIComponent( aParam[1] ) ;
FCKURLParams[ sParamName ] = sParamValue ;
}
})();