解决JS中取URL地址中的参数中文乱码

GET请求会将中文编码,如果取出乱码的话,应该进行解码操作,

下面的函数是获取指定参数名的参数值,参数值可是中文、英文。

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

注意: 需要在页面head中添加下面这个meta标签

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

原文地址:https://www.cnblogs.com/johnjackson/p/10435037.html