473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Pop up window not closing

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

Feb 10 '07 #1
4 1343
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

Feb 10 '07 #2
On Feb 10, 2:07 am, "tshad" <t...@home.comwrote:
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

..t

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

Feb 11 '07 #3
"Thomas Hansen" <po*******@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
On Feb 10, 2:07 am, "tshad" <t...@home.comwrote:
>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

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

Feb 12 '07 #4
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 [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:05**********************************@microsof t.com...
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,scrollb ars=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


Feb 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page...
10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
7
by: Miktor | last post by:
At the minute I am using the following rather unwieldy function to prevent the console window in Dev C++ from closing before I can see the output from my program: // function to prevent the...
10
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
4
by: bbass | last post by:
thanks to all that replyied to my previous post with the following code in question: <a href="merc.htm" target="_new_merc" onfocusout=window.close class="left_link"> i understand that the...
3
by: Saradhi | last post by:
Hi, I wanted to stop the VS.NET Window from closing inside my C# AddIn. I Know that OnBeginShutdown() funciton will be called whenever the user tries to close the VS.NET window. I want to...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
2
by: javanet | last post by:
Hi all, 1) i opened a parent window. 2) then i opend a child window thruogh this parent window. Now i want to close child window before closing the parend window means my clients can not be...
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
4
by: reemamg | last post by:
From a parent window a new child window is open with window.open <script type="text/javascript" language="JavaScript" > function abc() { if(window.event.clientY <0 &&...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.