Closing child window WITHOUT closing parent

Discussion in 'Javascript' started by thomas, Oct 23, 2003.

  1. thomas

    thomas Guest

    Hi guys

    I have a little problem: I am using another window to display images
    on my website. The problem is that when I close the child window, it
    closes the parent window too. I cannot find what is wrong.
    This window is created with the following script:

    function animUrl(url)
    {
    var p = 'scrollbars=yes,resizable=yes,toolbar=no,' +
    'menubar=no,status=no,location=no,left=85,top=20';

    var win = window.open("","animWindow",p);
    win.document.writeln('<html>');
    win.document.writeln('<head>');
    win.document.writeln('<link type="text/css" rel="stylesheet"
    href="mystyle.css">');
    win.document.writeln('<script src="fitToSize.js"></script>');
    win.document.writeln('</head>');
    win.document.writeln('<body id="animWindow"
    onload="fitToSize();">');
    win.document.writeln('<img name ="imgTag" src="' + url + '">');
    win.document.writeln('<p><a href="javascript:;"
    onclick="self.close();">Close
    window</a></p>');
    win.document.writeln('</body>');
    win.document.writeln('</html>');
    win.document.close();
    win.focus();

    return false;
    }

    fitTosize is a simple function to change the window dimension
    according to the image loaded:

    function fitToSize()
    {
    if( window.document.images )
    window.resizeTo(window.document.images[0].width+100,
    window.document.images[0].height+50);
    }

    Ca somebody explain me where is the error?
     
    thomas, Oct 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2lsZWVzaA==?=
    Replies:
    4
    Views:
    34,046
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Oct 14, 2004
  2. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    680
    Thomas Hansen
    Feb 15, 2007
  3. JohnE
    Replies:
    0
    Views:
    1,193
    JohnE
    Jan 10, 2010
  4. gokul
    Replies:
    3
    Views:
    784
    Grant Wagner
    Dec 2, 2003
  5. Spammay Blockay
    Replies:
    1
    Views:
    534
    Dietmar Meier
    Feb 4, 2005
Loading...

Share This Page