Solved

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

Posted on 2004-04-19
10
1,994 Views
Last Modified: 2011-09-20
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
Comment
Question by:athuranand
10 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 10863280
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 10863306
Use cookies.
You cannot rely on go(-1)
0
 

Author Comment

by:athuranand
ID: 10863389
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 10863418
try this:


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

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

Michel
0
 

Author Comment

by:athuranand
ID: 10863584
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 10863629
Yes it will Mozilla and NS6+ understand iframes
0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 250 total points
ID: 10863689
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javascript comparing two dates 3 20
jqury 17 30
How to create a textarea which saves text in HTML 8 37
Select case on click 3 16
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question