Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Communicating Between Open Windows 1

Status
Not open for further replies.

pwel

Programmer
Aug 18, 1999
79
GB
Hi All,

Here is one for you.

I have a page (page1.asp) which contains a form.
When the form button is clicked two things happen.
1) The form data is validated using ASP
2) A popup window is launched on the onClick event of the form button.

When the validation is done, the ASP redirects to another page (page2.asp) leaving the orphan popup window still open.

What I need to do, is close the popup window (created by page1.asp) when page2.asp loads.

I have tried everything but cannot get page2.asp to see the popup window.

Any help will be much appreciated.

Paul. Paul Welding
Web Developer
 
Try adding this to the popup page:

<script>
if (opener.document.location.href == &quot;page2.asp&quot;)
window.close();
<script>

You should call this code repeatedly, so add some timer that will run it.
 
Startway...... You are a star!!!!

This is how I eventually did it: -

<script language=&quot;Javascript&quot;>
function closePopup(){

if (!opener.document.location.href == &quot;summaryPrint.asp&quot;){
var t = setTimeout(&quot;closePopup()&quot;, 500);
}else{
window.close();
}
}
</script>

<body onLoad=&quot;closePopup();&quot;>

Thanks again.

Paul.


Paul Welding
Web Developer
 
That all seems a little unnecessary, why have a loop that eats resources when you could just put onload=&quot;window.open('javascript:self.close()','popUp')&quot; on page2.asp? Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top