javascript在html直接传值

    function getUrlParam(url, name) {
        var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
        var matcher = pattern.exec(url);
        var items = null;
        if (matcher != null) {
            try {
                items = decodeURIComponent(decodeURIComponent(matcher[1]));
            } catch (e) {
                try {
                    items = decodeURIComponent(matcher[1]);
                } catch (e) {
                    items = matcher[1];
                }
            }
        }
        return items;
    }

 console.log(getUrlParam(window.location.search, "customerid"));

  

 

posted @ 2017-08-16 17:43  WangJunZzz  阅读(442)  评论(0编辑  收藏  举报