獲取到當前網址
var url = window.location.href;
http://localhost:8080/exam_questions?type=3
//獲取url中的參數
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //構造一個含有目標參數的正則表達式對象
var r = window.location.search.substr(1).match(reg); //匹配目標參數
if (r != null) return unescape(r[2]); return null; //返回參數值
}
獲取到url中的type=后面的值
var xx = getUrlParam('type');