代码示例:(标识:jsref_history_go)
<!DOCTYPE html>
<html>
<head>
<script>
function goBack() {
  window.history.go(-2)
}
</script>
</head>
<body>

<button onclick="goBack()">后退两页</button>

<p>单击此处的“后退两页”按钮不会导致任何操作,因为历史列表中没有之前的 URL。</p>

</body>
</html>
运行结果: