一些常见的js(持续更新)

2020.10.30

从url获取值

//当前url地址栏 file:///C:/Users/admin/Desktop/test.html?id=2
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        console.log(window.location.search)//?id=2
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }
        

 

posted @ 2020-10-30 22:43  土拨鼠v1  阅读(61)  评论(0编辑  收藏  举报