This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Javascript - History browse back to prev page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript - History browse back to prev page" Watch "Javascript - History browse back to prev page" New topic
Author

Javascript - History browse back to prev page

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
My jsp page comes up on clicking "OK" on the previous page. Lets say the previous page name to be "prevScr" and present one to be "crntScr"

Now on the present jsp page, I perform some actions which would re-load the page again and again. The problem is there is a "Cancel" button on the current screen.

Here is code:

<td><html:button value="Cancel"
property="cancel" on click="javascript:history.go(-1);"></html:button>
</td>

When you click on it, it goes to the previous history and it shows the same "crntScr" (because I would have perfomed some actions that re-loaded the page) but what I really want is it should go to "prevScr" page.

Is there a method that identifies the previous page? Thank you for all your time and responses.

Luke.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do you want to skip back 2 pages? If you cahnge -1 to -2, would that do it for you?

Eric
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
Thanks Eric, but I do not have a account of how many pages we have to go back like 1 or 2. But everytime the page re-loads there should be some counter increment. Is there a way a dyanmic counter can be made so that we can go x number of pages back.

Thanks,
Luke.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 123
Hey,

Got the solution:
In the jsp:
<BODY on_load="incCounter">

<html:hidden name="ReceiptForm" property="counter"/>

function incCounter()
{
var cntr = document.forms[0].counter.value;
cntr--;
document.forms[0].counter.value = cntr;
}
<td><html:button value="Cancel" property="cancel"
on_click="windowHandle();"></html:button>
</td>
function windowHandle()
{
var x = document.forms[0].counter.value;
javascript:history.go(x);
}


In the ReceiptForm:
private int counter = 0;

Thanks Eric for all the help.
Luke.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript - History browse back to prev page