Solved

Parent Refresh/ Reload

Posted on 2008-09-30
16
727 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 3

Expert Comment

by:sam_norian
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:emzi19
Comment Utility
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
Comment Utility
Still getting nowhere with this. :S
0
 
LVL 3

Accepted Solution

by:
sam_norian earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad you got it working :-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now