469,319 Members | 2,277 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

Close Child Window via Parent using setTimeout

I would like to close a child window I opened from the parent using setTimout. I have tried these functions below, i succeed to open the window, but failed in closing it using the setTimeout function:

function 1
Expand|Select|Wrap|Line Numbers
  1. var sendWin;
  2. function sendWindow() {
  3. sendWin = window.open("http://www.google.fr");
  4. setTimeout("if (sendWin && !senWin.closed) sendWin.close()", 10000);
  5. }

function 2
Expand|Select|Wrap|Line Numbers
  1. function sendWindow() {
  2. var sendWin = window.open("http://www.google.fr");
  3. setTimeout(function() {
  4. if (sendWin && !senWin.closed) sendWin.close();
  5. }, 10000);
  6. }
Feb 25 '11 #1

✓ answered by Logic Ali

Expand|Select|Wrap|Line Numbers
  1.     var sendWin;
  2.     function sendWindow() {
  3.     sendWin = window.open("http://www.google.fr");
  4.     setTimeout("if (sendWin && !senWin.closed) sendWin.close()", 10000);
  5.     }
!!! Use the error console !!!!!(40 chars)

2 1194
Expand|Select|Wrap|Line Numbers
  1.     var sendWin;
  2.     function sendWindow() {
  3.     sendWin = window.open("http://www.google.fr");
  4.     setTimeout("if (sendWin && !senWin.closed) sendWin.close()", 10000);
  5.     }
!!! Use the error console !!!!!(40 chars)
Feb 25 '11 #2
(Responding to pm for clarification)

You wrote senWin instead of sendWin as highlighted in my reply. This would have generated an error message in the console, thus making the problem clear.

http://www.dreamincode.net/forums/to...error-console/
Mar 6 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Irvin Amoraal | last post: by
3 posts views Thread by John Smith | last post: by
Frinavale
5 posts views Thread by Frinavale | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.