Parent Refresh/ Reload

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 ?
emzi19Asked:
Who is Participating?
 
sam_norianConnect With a Mentor Commented:
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
 
sam_norianCommented:
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
 
emzi19Author Commented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
emzi19Author Commented:
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
 
sam_norianCommented:
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
 
emzi19Author Commented:
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
 
sam_norianCommented:
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
 
emzi19Author Commented:
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
 
sam_norianCommented:
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
 
emzi19Author Commented:
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
 
emzi19Author Commented:
Still getting nowhere with this. :S
0
 
emzi19Author Commented:
BUT if I put a form on the parent window called litresubmit with a hidden field that posts to itself would this work ?
0
 
emzi19Author Commented:
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
 
sam_norianCommented:
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
 
emzi19Author Commented:
It seems to work and is picking up the values so i'm very pleased! headache over!
0
 
sam_norianCommented:
Glad you got it working :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.