window
对象还提供了一个
history
对象,它与浏览器历史记录进行交互。该对象包含用户(在
浏览器窗口中)访问过的
URL
。方法如下表所示。
示例:
<a href="b.html">b.html</a>
<script>
console.log('-----------')
//history.forward();
history.go(1)
</script> <a href="a.html">a.html</a>
<script>
//history.back();
history.go(-1)
</script>