Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Parent Refresh/ Reload

Posted on 2008-09-30
16
Medium Priority
?
738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

688 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