JS获取URL中的GET参数

方法一;
function getLocationVal(id){    var temp = location.search.split(id+"=")[1] || "";    return temp.indexOf("&")>=0 ? temp.split("&")[0] : temp; }

方法二;;

function getArgs(){

    var args = {};

    var match = null;

    var search = decodeURIComponent(location.search.substring(1));

    var reg = /(?:([^&]+)=([^&]+))/g;

    while((match = reg.exec(search))!==null){

        args[match[1]] = match[2];

    }

    return args;

}

 getArgs();