js获取url传过来的参数2

<script type="text/javascript">
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 act=request('act');
alert(act);
</script>


by 雪洁 2014-02-21 07:37:03 2056 views
我来说几句

相关文章