Forum Moderators: open

Message Too Old, No Replies

Imergency Help About Back Function

In ASP

         

rpshah1208

7:35 am on May 23, 2006 (gmt 0)

10+ Year Member



Hi,

I want to go back two pages in asp with window.history.back() function.
So, how can i do that?

Pls carefully note that i want to go back two(2) pages.

Example:-i go for x.asp page, then y.asp page, then z.asp page. Now i want to go back x.asp page from here through a botton. How can i?

oxbaker

3:23 pm on May 23, 2006 (gmt 0)

10+ Year Member



The history object
The history object can be added to window. The history object can be used to move your user back or forward. The result is exactly the same as clicking the Back and Forward buttons on the browser toolbar. You can also use history.go() to move your users a specified number of pages either backwards or forwards. The history object works like this:

<Script language = JavaScript>

alert("Sorry, this page is under construction")

window.history.back()

</Script>

That script could go in say page2.html. On page1.html, there might be a link leading to page2.html. When the link is clicked, the above script will be executed in page2.html. The results is that first the alert box displays. Then the second line of code gets executed. This uses the back() method of the history object to take the user back to where they came from. The forward() method the same way, except your user will be taken forward one page in the browsing history.

To use the go() method of the history object, just type a number in between those two brackets. Like this:

window.history.go( -2 )

The minus two means back two pages. To go forward, just remove the minus sign (-).