Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2011
  • Last Modified:

History.go(-1) not working if pop up window is opened

I want to retain the user entered values by using history.go(-1). The following is the scenario

1. Main page is loaded (Contains code that instructs the browser to cache the page)
2. User enters the data in main page
3. Click submit button and this submits to a processing pae
4. In processing page, the data is insered to db
5. A Script is executed in process page...history.go(-1)
6. Main page is loaded again and previously entered values are retained.

I've a button in Main page. Onclick of the button will invoke a pop up window (Window name ABC, pop up page xyz.jsp). User will select some data in pop up page that will populate a field  (Using javascript)in Main page and will close the pop up window.

Now, if the user clicks submit button in Main Page, everything executes fine except that the Main Page is loaded again with BLANK data (USER ENTERED VALUES are not shown again even though I'm using history.go(-1))
 
Can this behavior of IE 6.0 be changed in anyway so that Main Page retains the values after submit using history.go(-1) (including the scenario where user visits pop up window) ?

I dont want to do major code change like using java beans or other mechanisms to retain Main page value. Thanks.
0
athuranand
Asked:
athuranand
2 Solutions
 
knightEknightCommented:
it is hard to tell without seeing your code ...
how are you opening the popup?
try setting the target of the form to the window name of the popup:

   window.open( "mypopup.jsp", "mypopup" );
   ...
   <form target="mypopup" ...
0
 
Michel PlungjanIT ExpertCommented:
Use cookies.
You cannot rely on go(-1)
0
 
athuranandAuthor Commented:
The following is the sample code

Main.jsp
   - Contains a button that will invoke Popu.jsp
   - On submit, invokes MyProcess.jsp
MyProcess.jsp
   - Contains a back button that will invoke history.go(-1)
Popup.jsp
   - This will populate a field in main page. Even a blank page wll do.

*******************************************************
Main.jsp(Main Page)
*******************************************************
<html>
<body>
<%
      response.setHeader("Cache-Control","public");
      response.setHeader("Pragma","cache");
      response.setDateHeader("Expires", 20160);
%>
<script>
function openWindow() {
      var popupWin=window.open('Popup.jsp','PopupPage','width=300,height=300,top=100,left=100');
      return true;
}
</script>
<form name="mytestform" method=post" action="MyProcess.jsp">
<input type="text" name="mytest" value="hello">
<input type="button" name="chooseme" value="open pop up window" onClick="openWindow();">
<br>
<input type="submit" value="Click Me" >
</form>
</body>
</html>
*******************************************************

MyProcess.jsp (Process Page)
*******************************************************
<html>
<body>
<form name="ProcessPage">
<input type="button" value="back" name="browserback" onclick="history.go(-1);">
</form
</body>
</html>

*******************************************************
Popup.jsp(Pop Up Page)
*******************************************************
<html>
<body>
<form action="xyz.jsp" name="mytest">
Welcome to pop-up
...
</form>
</body>
</html>

Hope this helps you to understand the issue
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Michel PlungjanIT ExpertCommented:
try this:


<form name="mytestform" method=post" action="MyProcess.jsp" target="myhidden">

.
.
<iframe height=1 width=1 name="myhidden" src="javascript:' '"></iframe>

Michel
0
 
athuranandAuthor Commented:
I forgot to add one information. Although I said I need solution in IE but our applications supports both IE 6.0 and Mozilla 1.6.  The sample code I've given works perfectly for Mozilla 1.6 but is not working in IE. I believe iframe solution wont work for Mozilla. Sorry about that.
0
 
Michel PlungjanIT ExpertCommented:
Yes it will Mozilla and NS6+ understand iframes
0
 
ZvonkoSystems architectCommented:
The regular way of doing that what you want to do is this:

Main.jsp(Main Page)
*******************************************************
<html>
<body>
<%
     response.setHeader("Cache-Control","public");
     response.setHeader("Pragma","cache");
     response.setDateHeader("Expires", 20160);
%>
<script>
function openWindow() {
     var popupWin=window.open('Popup.jsp','PopupPage','width=300,height=300,top=100,left=100');
     return true;
}
</script>
<form name="mytestform" method=post" action="MyProcess.jsp">
<input type="text" name="mytest" value="<%=mytest%>">
<input type="button" name="chooseme" value="open pop up window" onClick="openWindow();">
<br>
<input type="submit" value="Click Me" >
</form>
</body>
</html>
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now