$("body").click(function(){ //html获取链接上面的参数 function getQueryString(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r!=null) return r[2];else return''; } var type = getQueryString('type'); if(type=='1'){ alert(123); location.replace("文件路径"); }else if(type=='2'){ alert(456); location.replace("文件路径"); } getQueryString('name'); }); URL:applyFor.html?userId=1 function getQueryVariable(variable){ var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } var userId = getQueryVariable("userId"); //system/index.html var url; url = window.location.pathname; url = url.substring(url.lastIndexOf('/') + 1, url.length); console.log(url) 打印出来就是:index.html