H I O X INDIA
Javascript Tutorial
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





History Go Method


Topic

How to move to a certain page in history list using javascript



Explanation

Methods or Function: go()
        go() function takes one argument. It can take an integer argument or a string argument.

Code: go(n);
where n can be a negative, zero or positive integer.
a) if n<0, it takes to the previous pages in the history list. i.e go(-1) takes to previous page, go(-2) takes two page back and so on..

b) if n=0, nothing happens

c) if n>0, it takes to the next pages in the history list. i.e go(1) takes to next back, go(2) takes two pages ahead and so on..

Example: To create a button that loads two pages backward using javascript.
Code:
<script language="javascript">
function gourl(){
history.go(-2);
}
</script>
<input type=button value="go back" onClick=gourl()>

Result:
In the above example
a) we created a button
b) added a onClick event listener to the button.
c) when user clicks on the button the javascript function gourl()
will be invoked.
d) in the function we call history.go(-2) to go two steps backward.




        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links