Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2004, 05:21 AM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sherbir
Default Make child close automatically after 3 seconds

Hi all,
Here's the problem.

I am opening a child window from a parent window using the window.open() method, and then rendering an image and some text in the child window using document.write() method .

I want to actually implement the child as a popup window and then close the child after 3 seconds of activation.

Here's the javascript function that does all that on clicking a button in the parent :

function open_win()
{
    var x=window.open("","win1","menubar=no toolbar=no width=300 height=150");
    x.moveTo(screen.AvailWidth/3,screen.AvailHeight/3);
    x.document.write("<center>");
    x.document.write("<table bgcolor='steelblue'>");
    x.document.write("<tr><td align=center><b>Saving the File...</b></td></tr>");
    x.document.write("<tr>");
    x.document.write("<td align=center><img src=upload_img.gif></td>");
    x.document.write("</tr>");
    x.document.write("<tr>");
    x.document.write("<td align=left>");
    x.document.write("This may take a few minutes.<br>Please Wait...");
    x.document.write("</td>");
    x.document.write("</tr>");
    x.document.write("<tr><td>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</td></tr>");
    x.document.write("</table>");
    x.document.write("</center>");
    setTimeout('self.close()',3000);
}

It's not working. The child window stays as is.

How do I make the child close automatically after 3 seconds ?

Any ideas ??

Regards,
Sherbir
__________________
Regards,
Sherbir
 
Old August 25th, 2004, 02:32 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You're setTimeout line is calling to close the current window when you want to close the child window.

So, just replace 'self' with 'x'.

HTH,

Snib

<><
 
Old August 25th, 2004, 11:24 PM
Authorized User
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sherbir
Default

Quote:
quote:Originally posted by Snib
 You're setTimeout line is calling to close the current window when you want to close the child window.

So, just replace 'self' with 'x'.

HTH,

Snib

<><
Thanx alot buddy !!
It worked ! :D

Regards,
Sherbir





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat window close automatically Edward King Apache Tomcat 1 July 5th, 2011 05:59 AM
Close Child window automatically on closing parent vikas67k C# 1 August 26th, 2008 02:00 AM
Tip: How to open/close CDROM automatically crmpicco Javascript How-To 3 April 9th, 2008 05:30 AM
How to close window automatically? Edward King Javascript How-To 1 June 17th, 2004 11:56 AM
Close in the load event on child form gvozden VB.NET 0 October 22nd, 2003 10:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.