PDA

View Full Version : Window won't close


SYP}{ER
03-14-2003, 01:10 PM
var beenOpened = false;
function enlarge (what,w,h) {
if (!w && !h) {
window.location = what;
}else{
if (beenOpened) {
if (wwin.closed){
alert (wwin.close());
}
}
wwin = window.open (what,'TheWin','width='+w+',height='+h+',resizable=yes');
beenOpened = true;
wwin.focus();
}
return false;
}

I need a window to open which is a certain size. But when I call the function again, I need window of another size to open so I must first close the old window. (resizeTo resizes the window including the chrome. I need to size the frames exactly so I must use window.open again)

For some reason, the window isn't closing :(

Any ideas?

Cris79
03-14-2003, 02:34 PM
Maybe this will give you an idea.

<HTML>
<HEAD>
<TITLE></TITLE>
<script>
cek = 0;
function enlarge (what,n,w,h)
{
// window.location = what;
if (cek==1){wwin.close();}
wwin = window.open(what, n ,'width='+w+',height='+h+',resizable=yes');
cek = 1;
wwin.focus();
// return false;
}
</script>
</HEAD>
<BODY>
<input type="button" value="1" onclick="enlarge('first.htm','w1', 200, 200)">
<input type="button" value="2" onclick="enlarge('second.htm','w2', 300, 300)">
</BODY>
</HTML>

This is work only if you don't close the new window with "x". :)

SYP}{ER
03-15-2003, 02:53 AM
Works in Mozilla but not IE...

Probably my stupid firewall's ad-blocking script that is being inserted into my site's source :( Can't seem to get rid of it.

glenngv
03-15-2003, 05:33 AM
function enlarge (what,w,h) {
if (!w && !h) {
window.location = what;
}else{
if (wwin && !wwin.closed) wwin.close();
wwin = window.open (what,'TheWin','width='+w+',height='+h+',resizable=yes');
wwin.focus();
}
return false;
}