Pop up window not closing

T

tshad

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,scrollbars=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
 
G

Guest

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=...ble=no,scrollbars=no,location=no,status=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>
 
T

tshad

Thomas Hansen said:
I have a couple of windows I am opening from my .aspx window and want the
[snip]

Don't use popup windows, use: http://ajaxwidgets.com/
AllControlsSamples/Window.aspx

Looks pretty good.

But the objects seem to be for Asp.net 2.0 and I am using 1.1.

Also, I use an ajax style program called Anthem that works really well.
Would these objects have a problem with this?

Thanks,

Tom
 
T

tshad

That was what I was looking for.

I didn't realize I had to actually define the window. I thought my open
window call was doing it.

Thanks,

Tom
Milosz Skalecki said:
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=...ble=no,scrollbars=no,location=no,status=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 said:
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,scrollbars=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
 

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,902
Latest member
Elena68X5

Latest Threads

Top