js切り取りurlアドレスの文字列パラメータ方法

695 ワード

eg:http://localhost:63342/appwork/detail/detail.html?classId=xc56719940694a7c82948895de87801b&isShow=true
function GetRequest() {
    var url = decodeURI(location.search); //  url "?"     
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for ( var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
var Request=undefined;
Request=GetRequest();
var classId = Request["classId"];
var isShow = Request["isShow"];