瀏覽器輸入頁面地址的時候在后面帶有請求參數, 頁面加載后需要獲取攜帶的參數, 可以使用js, 在頁面加載js的時候獲取參數
http://localhost:8080/demo/index.html?id=1&name=2
$(function(){
var id= GetPar("id");
var name = GetParam("nam"); function GetPar(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r != null) return decodeURIComponent(r[2]); return null; }
});