2013年1月18日 星期五

javascript 取得網址的URL參數和值



參考 http://www.yes-seo.tw/2011/04/javascript-get-url/


function Get_URL_Parameter(sParameter)
{
var url=window.location.toString();
var str="";
var str_value="";
if(url.indexOf("?")!=-1){
var ary=url.split("?")[1].split("&");
for(var i in ary){
str=ary[i].split("=")[0];
if (str == sParameter) {
str_value = decodeURI(ary[i].split("=")[1]);
}
}
}
return str_value;
}

0 意見:

張貼留言

 

MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template