Breaking News
yeni film izle hd film seyret film izle

DOM History IN JavaScript

 
History object contains information about the URLs user has accessed or visited using browser window. When a user access a web page the details of that web page are stored on computer by browser in form of history. We can access these details using the history object .The properties and methods of history object are listed below.
 
Properties:
Length
 
Methods
Back()
Forward()
Go()
 
 
Properties
length
 
length property of history object returns total number of elements in history list. The number of objects in the history list may be different at different times because generally person do not visit same number of pages. Length property returns us the total number of pages available in history collection.
 
Example:
 
<html>

<head>

</head>

<body>

<blockquote> history length will tell you that how many

elements are in history list </blockquote>

<script type=”text/javascript”>

document.write(history.length)

</script>

</body>

</html>

Click here to view result of this program on browser
 
 
Method
Back()
 
This history object’s method loads the previous URL in the history list. The page we just left after moving to new page is history for current page. We can access the previous page by using back() method. This method will drop us back to the previous page.
 
Example:
 
<html>

<head>

</head>

<body>

<blockquote>If any page is opened in the browser before

 

this page the it will call that page back </blockquote>

<script type=”text/javascript”>

function ff()

{

history.back()

}

</script>

<input type =”button” value=”hit me to go back ” name=”b1″

onclick=”ff()”>

</body>

</html>

Click here to view result of this program on browser
 
 
Forward()
 
This history object’s method loads the next URL in the history list. There is a list page name in history. To go to the page next to current page or url can be accessed by forward () method. It will drop us on the next page to current page.
 
Example:
 
<html>

<head>

</head>

<body>

<blockquote>If any page is opened in the browser before

 

this page the it will call next page</blockquote>

<script type=”text/javascript”>

function ff()

{

history.forward()

}

</script>

<input type =”button” value=”hit me to go forward “

 

name=”b1″ onclick=”ff()”>

</body>

</html>

Click here to view result of this program on browser
 
 
go()
 
This history object’s method loads the specified web page number in the history list. To load any page in history we can use go () method. This method calls the specified web page and loads it on browser.
 
Example:
 
<head>

</head>

<body>

<blockquote>It will call the specified page number inthe

history list</blockquote>

<script type=”text/javascript”>

function ff()

{

history.go(-2)

}

</script>

<input type =”button” value=”hit me to go forward “

name=”b1″ onclick=”ff()”>

</body>

</html>

Check Also

Functions Returning Values In Java Script

Function is a set of statements recognized by a name and can be used as …