首页 > 代码库 > js获得url内的参数

js获得url内的参数

 

 

        /**         * js获得url内的参数         * 返回值: string or undefined         * 使用方法:$_GET[‘from‘]         */        var $_GET = (function() {        var search = location.search;        if (search == ‘‘)        {            return {};        }        search = search.split(‘?‘)[1];        search = search.split(‘&‘);        var get = {};        for (var i in search)        {            var j = search[i].split(‘=‘);            get[j[0]] = j[1];        }        return get;        })();

 

js获得url内的参数