codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How do I make the child close automatically after 3 seconds ?  sherbir at 11:07 on Wednesday, August 25, 2004
 

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("<body onLoad='window.close()'>");
x.document.write("<center>");
x.document.write("<table bgcolor='steelblue'>");
x.document.write("<tr><td align=center><font face=tahoma size=3 color=lime><b>Saving the File...</b></font></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("<font face=tahoma size=3 color=white>This may take a few minutes.<br>Please Wait...</font>");
x.document.write("</td>");
x.document.write("</tr>");
x.document.write("<tr><td>        </td></tr>");
x.document.write("</table>");
x.document.write("</center>");
x.document.write("</body>");
}

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

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

Any ideas ??




  Re: How do I make the child close automatically after 3 seconds ?  Troy Wolf at 15:14 on Wednesday, August 25, 2004
 

Remove the onload event handler from the body tag. Then make the last thing you write to the window a small javascript snippet that makes use of the setTimeOut window method. You can pass self.close() to that function.

In fact, the devguru documentation for the javascript setTimeOut method shows you how to do almost exactly what you want.
http://www.devguru.com/Technologies/ecmascript/quickref/win_settimeout.html
Troy Wolf: site expert
Shiny Solutions


  Re: How do I make the child close automatically after 3 seconds ?  sherbir at 05:21 on Thursday, August 26, 2004
 

Thanx alot Troy !!

It worked !!










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: help: location of an element within a collection
•  Help with a form
•  Re: Response.Redirect is not working
•  Re: tellafriend
•  Re: Code Snippets
•  Re: Software Planning
•  Re: Set up file Down Load
•  Re: open excel file in html page
•  Re: How to open a .DOC file in MS-Word thru a link


Recent Articles
Simple Thumbnail Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)
Function to Return Alpha Characters Only
The OSI Reference Model - A Clear and Concise Illustration !


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004