JS 获取参数、封装

 var common = {
          getQueryString : function(name){
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
            var r = '';
            try{
                r = location.href.split('?')[1].match(reg);
            }catch(err){}
            if (r != null && r != 'undefined') {
                return unescape(r[2]);
            }
            return null;
          }
      }
原文地址:https://www.cnblogs.com/liubingyjui/p/13201330.html