Click to See Complete Forum and Search --> : window.close
dsdsdsdsd
05-19-2004, 09:54 AM
hello;
if I
window.open("http://www.hotmail.com","_blank","width="+w+", height="+h+", left=350 , top=0 , scrollbars=yes , menubar=yes");
how can I later close that window; I am not seemingly able to use window.close;
any thoughts?
thanks
Shannon Burnett
Asheville NC USA
TheBearMay
05-19-2004, 10:06 AM
Try something like:
var wHndl = window.open(.....)
wHndl.close();
dsdsdsdsd
05-19-2004, 11:54 AM
hello thebearmay; thanks for responding;
this window.open() is running client-side;
Shannon Burnett
Asheville NC USA
TheBearMay
05-19-2004, 12:02 PM
Should work then. The open statement will return a handle to the variable wHndl, which can then be used by the script to close the popup.
Khonsu
05-20-2004, 02:09 AM
You can control a pop-up window from the main page by assigning it to a global variable, for example:
<script language="JavaScript">
var myWindow
function openWindow() {
myWindow = window.open('http://www.example.com');
}
function closeWindow() {
myWindow.close()
}
</script>
The main thing to remember is that the variable must be global, i.e., not initialized within a function (though it's value can be set within a function, as above) if you want other functions to have access to it.
dsdsdsdsd
05-20-2004, 02:19 PM
hello thebearmay; I completely missed the point of your first post which is to capture the window.open resource handler; sorry;
Khonsu thanks for your response;
thanks
Shannon Burnett
TheBearMay
05-20-2004, 02:28 PM
No problem, I should have better explained why I was doing it instead of leaving you to guess.