从一个html页面传值到另一个页面(js location.search用法)

160 阅读1分钟

a.html 页面A

var id = 10000
window.location.href = "updataPersonnel.html?id=" + id

b.html 页面B

var empId
var url = window.location.search //获取url中"?"符后的字串  
if(url.indexOf("?")!=-1){
    empId = url.substr(url.indexOf("=")+1)
}
console.log(empId)

控制台打印