去往详情页之后定位到原来的位置

pushHistory();//监听页面回退
window.addEventListener("popstate", function(e) {
$(location).attr('href', './index.html?index='+index+"&parm=true");
}, false);
function pushHistory() {//监听页面回退
var state = {
title: "title",
url: "./index.html"
};
window.history.pushState(state, "title", "./index.html");
}





var index=0;
if(params.index){
index = params.index;
}
var href="#index"+index;
$("#a").attr("href",href)
console.log(params)
if(params.parm){
setTimeout(function() {//按钮自动点击事件实现
if(document.all) {
document.getElementById("a").click();
}
else {
var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("a").dispatchEvent(e);
}
}, 200);

}
原文地址:https://www.cnblogs.com/liuerpeng/p/9965687.html