js获取get传递的值

<script language="javascript" src="js/jquery-1.9.0.min.js"></script>
<script>

function Request(argname)
{
    var url = document.location.href;
    var arrStr = url.substring(url.indexOf("?")+1).split("&");
    for(var i =0;i<arrStr.length;i++)
    {
       var loc = arrStr[i].indexOf(argname+"=");
       if(loc!=-1)
       {
        return arrStr[i].replace(argname+"=","").replace("?","");
        break;
       }
    }
    return "";
}

$(document).ready(function(){
    var a = Request('a');  //a的指 http://www.abc.com?a=1&b=2&c=3 中的a,也可以放b或者c
    if(a == '3') $('ul li').eq(0).hide();
});
</script>

 

posted @ 2013-09-14 17:22  jshaibozhong  阅读(393)  评论(0编辑  收藏  举报