Close Child Window via Parent using setTimeout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Melanie Cohl
    New Member
    • Feb 2011
    • 1

    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
    Code:
    var sendWin;
    function sendWindow() {
    sendWin = window.open("http://www.google.fr");
    setTimeout("if (sendWin && !senWin.closed) sendWin.close()", 10000);
    }

    function 2
    Code:
    function sendWindow() {
    var sendWin = window.open("http://www.google.fr");
    setTimeout(function() {
    if (sendWin && !senWin.closed) sendWin.close();
    }, 10000);
    }
    Last edited by Niheel; Feb 25 '11, 04:39 PM.
  • Logic Ali
    New Member
    • Jul 2010
    • 16

    #2
    Code:
        var sendWin;
        function sendWindow() {
        sendWin = window.open("http://www.google.fr");
        setTimeout("if (sendWin && ![B]senWin[/B].closed) sendWin.close()", 10000);
        }
    !!! Use the error console !!!!!(40 chars)

    Comment

    • Logic Ali
      New Member
      • Jul 2010
      • 16

      #3
      (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.

      Comment

      Working...