有一种解决方法,可以在现代浏览器上使用历史记录API,而在旧浏览器上进行回退:
if(history.pushState) {
history.pushState(null, null, '#myhash');
}
else {
location.hash = '#myhash';
}
如何在不跳文档的情况下更新window.location.hash?
有一种解决方法,可以在现代浏览器上使用历史记录API,而在旧浏览器上进行回退:
if(history.pushState) {
history.pushState(null, null, '#myhash');
}
else {
location.hash = '#myhash';
}