Solved

Parent Refresh/ Reload

Posted on 2008-09-30
16
729 Views
Last Modified: 2012-06-27
Hi,

I have an ASP page with a link on it that opens a pop-up window which allows the user to change a record. When the user closes this pop-up window i have a javascript command there to refresh the parent page.

onclick="window.close(); if (window.opener && !window.opener.closed) {window.opener.location.reload();}"

However, the alert comes up "to display the page again internet explorer needs to re-send the information you have submitted... "

Is there a cleaner way of doing this so the above alert does not appear ?
0
Comment
Question by:emzi19
  • 9
  • 7
16 Comments
 
LVL 3

Expert Comment

by:sam_norian
ID: 22604629
Hi,

You could use:

onclick="window.close(); if (window.opener && !window.opener.closed) {javascript:window.opener.location='http://www.myurl.com/mypage.asp?update=true';}"

instead of:

onclick="window.close(); if (window.opener && !window.opener.closed) {window.opener.location.reload();}"

HTH,

Sam
0
 

Author Comment

by:emzi19
ID: 22604872
I've gone for a different approach with a form with a hidden field

<script>
function bs()
{
window.opener.document.forms['litresubmit'].submit();
window.close();
return false;
}
</script>

  <p><input type="button" value="                Close Window                 "  onclick="javascript:bs"></p>

<form action="vehicleindexlist.asp?vmake=<%response.write(vmake)%>&vmodel=<%response.write(vmodel)%>" method="post" name="litresubmit">
<input name="form_submodel_option" type="hidden" value="<% response.write(vlitre) %>" />

</form>

however its not loading the javascript event. I'll try the method you have suggested.
0
 

Author Comment

by:emzi19
ID: 22604954
Thanks for your response sam.

tried it, but its not passing the variables back so isnt displaying the correct data, just "no results found". I need it to re-submit the values and send a form to get the vlitre option to display in the parent page. Why when i click on close window does it do nothing and not load my function, function bs()
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 3

Expert Comment

by:sam_norian
ID: 22605305
Is that all of the code for the pop up window?

It might be u need the Parenthesis:

onclick="javascript:bs()"

Can the vlitre option not be sent through the Querystring?

Sam
0
 

Author Comment

by:emzi19
ID: 22605381
It cant be sent through querystring as various pages use the parent page and it calls it from a form.

Still does nothing when i press the close window button



<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Vehicle</title>
<style type="text/css">
<!--
body {
	background-color: #FFFFFF;
}
.style9 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
-->
</style>
 
<script>
function bs()
{
window.opener.document.forms['litresubmit'].submit();
window.close();
return false;
}
</script>
 
 
 
</head>
 
<% 
 
   vmake = request.querystring("vmake")
   vmodel = request.querystring("vmodel")
   vlitre = request.querystring("vlitre")
   
   
		'CONNECTS TO THE DATABASE TO ADD NEW VEHICLE DETAILS
Dim adoCon             
Dim SQL
Dim Recordset2
 
Set adoCon = Server.CreateObject("ADODB.Connection")
 
adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../Data/database.mdb"))
SQL = "SELECT * FROM vindex WHERE VehID="& request.querystring("id") &""
Set recordset2 = Server.CreateObject("ADODB.Recordset")
 
recordset2.Open SQL, adoCon, 3, 3
 
recordset2.delete%>
 
 
 
 
<body>
 
<div align="center">
  <p class="defaultTbl style9">Record 
    <% response.write request.querystring("id") %> 
    Deleted</p>
</div>
<form action="vehicleindexlist.asp?vmake=<%response.write(vmake)%>&vmodel=<%response.write(vmodel)%>" method="post" name="litresubmit">
  <div align="center">
  <input name="form_submodel_option" type="hidden" value="<% response.write(vlitre) %>" />
  <input type="button" value="                Close Window                 "  onclick="javascript:bs()">
  </div>
</form>
 
</body>
<% adoCon.close
Set AdoCon = nothing
Set Recordset2 = nothing
%>
</html>

Open in new window

0
 
LVL 3

Expert Comment

by:sam_norian
ID: 22605571
Does it throw an error when you click the button?

Do you have an online example of this page/ parent page I can look at?
0
 

Author Comment

by:emzi19
ID: 22605752
I do have an online version but its all password protected etc. so prefer not to post address here for security reasons. It throws no errors, just doesnt do anything at all. I'm very baffled, pulling my hair out and wondering why!
0
 
LVL 3

Expert Comment

by:sam_norian
ID: 22605927
No probs I understand, may have to ask some more questions before we get to the bottom of this...

Do you get an icon like below after you click the button? (IE only,if your using FireFox go to Tools > Error Console) if you do double click it, it should say where the script is going wrong.

Is litresubmit a form on the parent page?

Can you post the code for the link or button that opens this window?

Untitled.jpg
0
 

Author Comment

by:emzi19
ID: 22606028
There is no grey strip along the bottom of the pop-up window and no javascript error icon. I tried to get the status bar in the popup window by changing some code on the parent window, but its still not appearing. See below code for the code used to load the popup window.

litresubmit isnt a form on the parent page. litresubmit is a form in the child popup window which we are trying to postback to the parent window. The parent window then uses request.form to receive the litre value and also picks up make and model from querystrings.
function popUp3(URL) {
  if (confirm('Are you sure you want delete this vehicle?')) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=400,height=150,left = 590,top = 175');");

Open in new window

0
 

Author Comment

by:emzi19
ID: 22607004
Still getting nowhere with this. :S
0
 
LVL 3

Accepted Solution

by:
sam_norian earned 50 total points
ID: 22607208
Ok when you execute...

 window.opener.document.forms['litresubmit'].submit();

...you are telling the parent page to submit a form that doesn't exist (the form is on the pop up page).

You could try and do something by adding the target property to the form tag....But even then i'm not sure you would get the result you are after.

The only way I can think to make this work is parsing the variables through the URL.

Sorry I can't be more help.



0
 

Author Comment

by:emzi19
ID: 22609065
BUT if I put a form on the parent window called litresubmit with a hidden field that posts to itself would this work ?
0
 

Author Closing Comment

by:emzi19
ID: 31501510
thanks for your help sam. I didnt realise it was trying to submit the form from the parent page, switching the form location and posting the form to itself has solved my problem.
0
 
LVL 3

Expert Comment

by:sam_norian
ID: 22612405
Hmmm... It will allow you to post the form, the problem will be dynamically setting the value of the hidden field on the parent page (it will have to post back to set the value).

You may also be able to achieve what you want using cookies...
0
 

Author Comment

by:emzi19
ID: 22612776
It seems to work and is picking up the values so i'm very pleased! headache over!
0
 
LVL 3

Expert Comment

by:sam_norian
ID: 22618831
Glad you got it working :-)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

778 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