JS获取URL地址栏中的参数

<script type="text/javascript">
        $(function () {
            var url_arr = GetURLRequest(window.location.href).split('|'); //获取当前页REQUEST集合,并存入数组。
            alert(url_arr);
        });
        function GetURLRequest(Url) {
            var u, g, StrBack = '', RETURNVALUE = "";
            if (arguments[arguments.length - 1] == "#") { u = Url.split("#"); } else { u = Url.split("?"); }
            if (u.length == 1) g = ''; else g = u[1];
            if (g != '') {
                gg = g.split("&");
                var MaxI = gg.length;
                str = arguments[0] + "=";
                for (xm = 0; xm < MaxI; xm++) {
                    if (gg[xm].indexOf(str) == 0) {
                        StrBack = gg[xm].replace(str, "");
                        break;
                    }
                    RETURNVALUE += gg[xm].substring(gg[xm].indexOf('=') + 1) + "|";
                }
            }
            return RETURNVALUE.substring(0, RETURNVALUE.length - 1);
        }

    </script>

posted @ 2013-05-19 12:30  BicycleBoy  阅读(243)  评论(0编辑  收藏  举报