11.30随笔

//jquery获取url参数方法

function request(paras) {
            var url = location.href;
            var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
            var paraObj = {}
            for (i = 0; j = paraString[i]; i++) {
                paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
            }
            var returnValue = paraObj[paras.toLowerCase()];
            if (typeof (returnValue) == "undefined") {
                return "";
            } else {
                return returnValue;
            }
        }

 

使用方法:

var type = request("FLI");  (如地址为:www.sssssss.com/FLI=AAA

posted @ 2013-11-30 19:03  觉信  阅读(114)  评论(0编辑  收藏  举报