asp和js获取当前网页地址和参数的例子

来源:互联网 发布:网络语喵喵喵什么意思 编辑:程序博客网 时间:2024/04/29 11:18
 

'asp 获取网页地址及参数

function getwebpageurl()
dim host,keyword
host = Request.ServerVariables("HTTP_HOST")    '获取域名
keyword = Request.ServerVariables("QUERY_STRING")    '获取参数集
variable = Request.ServerVariables("PATH_INFO")  '获取网页路径

if keyword <> "" then 
getwebpageurl = "http://" &host&variable&"?"&keyword 
else 
getwebpageurl = "http://" &host&variable
end if 
end function 

'js获取网页地址及参数

var url=location.search; //获取参数集
var url2 = window.location.href ;  获取全路径

if( url.indexOf("?")!=-1){

 var str = url.substr(1);
  strs = str.split("&");
  for(var i=0;i<strs.length;i++) {
 document.write(strs[i].split("=")[0] +" = "+ strs[i].split("=")[1] + "/n");
  }

}

原创粉丝点击