Closing child window WITHOUT closing parent

T

thomas

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top