history 对象是 window 对象的属性,它保存着用户上网的记录,从窗口被打开的那一刻算起。
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>正则表达式</title> <script type="text/javascript"> function back() { //跳转到前一个 URL history.back(); } function forward() { //跳转到下一个 URL history.forward(); } function go(num) { //跳转指定历史记录的 URL history.go(num); } </script> </head>
可以通过判断 history.length,得到是否有历史记录和记录数。
原文:http://www.cnblogs.com/LO-ME/p/3602900.html