js跳转页面传参多个参数

  • Post author:
  • Post category:其他


js跳转页面传参多个参数



js跳转页面传参多个参数

1、获取courseID和studentID

//获取courseID和studentID
//页面地址:
window.location.href='../yemian/video.html?courseID='+cid+‘&studentID=’+sid;

2、参数获取方法

function GetRequest() {
        var url = location.search.trim(); //获取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]] = (strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }

3、调用getrequest方法,接收参数

    var Request = new Object();
    var buid =GetRequest()['courseID'];
    var sid =GetRequest()['studentID'];

4、在页面加载时导入代码

PS:原博文地址:

https://blog.csdn.net/liqi939597/article/details/86634690



版权声明:本文为Songldoudou原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。