Howdy,
This is because 'myWindow' is undefined identifier (it is not automatically
added to properties of the current window). I changed the code so it will
handle
as many windows as you create:
<body onunload="CloseOpenedWindows()">
<form id="form1" runat="server">
<button onclick="OpenLogoPreviewWindow()">Create a window</button>
<script type="text/javascript">
var openedWindows = new Object();
function OpenLogoPreviewWindow()
{
var wndName = 'myWindow';
var wnd =
window.open('http://www.wp.pl',wndName,'menubar=no,toolbar=no,director ies=no,resizable=no,scrollbars=no,location=no,stat us=no');
if (wnd)
{
eval('openedWindows.' + wndName + ' = wnd;');
}
else
{
alert('please unblock popup blockers');
}
}
function CloseOpenedWindows()
{
for (var wndName in openedWindows)
{
openedWindows[wndName].close();
}
}
</script>
</form>
</body>
--
Milosz
"tshad" wrote:
I have a couple of windows I am opening from my .aspx window and want the
child windows to close when the browser closes or I change pages.
I have the following to open the window:
function OpenLogoPreviewWindow()
{
window.open('logoDisplay.htm','myWindow','menubar= no,toolbar=no,directories=no,resizable=no,scrollba rs=no,location=no,status=no');}And in my Page_Load routine I have the following to add to my body tag: myBody.attributes.Add("onUnload","myWindow.close() ")And when I do a view source the body tag shows as:<body id="myBody" onUnload="myWindow.close()">But the window stays open when I go to a new page of close the window. Ialso tried to set a timer to close the window but it won't close either.Is this something from Asp.Net that is stopping this?ThanksTom