js 获取ul地址栏的参数的值

定义:

    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

ul值:

window.location.href=
"http://localhost:32906/JingTing/book?bookId=eeff71eb-a9df-4c18-869c-bebdab02f85a&userId=8915a5f2-fd61-464b-b79b-97c09647c89f&dayindex=2&appkey=eusoft_ting_en_android&version=7.4.0&token=UabkubBi9LdI2UsdbhBAW1aZMSU="

调用:

$.getUrlParam("userId")//获取参数userId的值

结果:

8915a5f2-fd61-464b-b79b-97c09647c89f

猜你喜欢

转载自blog.csdn.net/wcy7916/article/details/86575463