html跳轉,獲取get提交參數

html跳轉到html頁面,url後面攜帶參數,能夠經過腳本獲取到url?test=value地址後的參數。javascript

一、more.html 攜帶參數跳轉到list.html,get提交參數html

二、list.html  獲取more.html提交過來參數java

一、more.html:url

<script>
function test() {
    window.location.href = "list.html?test=value";
}
</script>

二、list.html:spa

 

<script type="text/javscript">
function GetRequest() {
    var url = 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;
}
$(document).ready(function () {
    var Request = new Object();
    Request = GetRequest();
    var val= Request["test"];  
    alert(val);
});

</script>
相關文章
相關標籤/搜索