IE Browser back button goes to two pages back
I am not using JSPs, using a servlet ABSServlet to display the search page, after entering the search criteris I'm displaying a report page. The report page has a button 'Save As Excel' which open the report in the Excel form. When I click on this button browser asks 'Open' or 'Save'. I clicked on 'Open'. It open the report in excel form in the same page. Now if I press the IE Browser back button it takes me to the Search page instead of the report page.
Ideally it should go back to the Report page(preiosu page) if I click the back button and not to the previous to previous page. Can someone help?
[627 byte] By [
krajnisha] at [2007-11-27 9:52:49]

# 1
You cannot (practically) modify the function of the browser's back button...
You can patch it though.
Put in the intermediate (search) page something like
<script language="Javascript"><!--
function sendBack()
{
wherefrom=history.forward(1); //only valid if the back button has been used. otherwise null
length=wherefrom.length();//length of 'forward page's url'
if (history.forward(1).substring(length-4)==".xls") //the back button has been press on a url ending .xls - back from a spreadsheet
{
location.href=history.back(1); //go back once more from here
}
else
{
//this is if the back button was not used or if back button was used from a page that is not an excel spreadsheet;
//if you write nothing here, the page just display as though this function were not here
}
}
//--></script>
<body onload="sendback()">
Not really a Java solution, but should work.
Bamkin :-)