JavaScript Wind...LOGIN

JavaScript Window History

JavaScript Window History

The window.history object contains the history of the browser.

Window History

The window.history object can be written without using the window prefix.

In order to protect user privacy, JavaScript’s method of accessing this object is restricted.

Some methods:

history.back() - Same as clicking the back button in the browser history.forward() - Same as clicking the forward button in the browser

Window History Back

The history.back() method loads the previous URL in the history list.

This is the same as clicking the back button in the browser:

Create a back button on the page:

<html>
<mate charset="utf-8">
<head>
<script>
function goBack()
  {
  window.history.back()
  }
</script>
</head>
<body>
<input type="button" value="返回" onclick="goBack()">
</body>
</html>

Window History Forward

history forward() method loads the next URL in the history list.

This is the same as clicking the forward button in the browser:

Create a forward button on the page:

<html>
<mate charset="utf-8">
<head>
<script>
function goForward() 
 { 
  window.history.forward() 
   }
</script>
</head>
<body>
  <input type="button" value="下页" onclick="goForward()">
</body>
</html>


Next Section
<html> <mate charset="utf-8"> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="返回" onclick="goBack()"> </body> </html>
submitReset Code
ChapterCourseware