码迷,mamicode.com
首页 > 编程语言 > 详细

javascript在html直接传值

时间:2017-08-16 18:22:48      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:reg   try   param   sea   blog   ges   null   exp   mat   

    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"));

  技术分享

 

javascript在html直接传值

标签:reg   try   param   sea   blog   ges   null   exp   mat   

原文地址:http://www.cnblogs.com/WJ--NET/p/7374614.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!