Popup window will not close on IE6 XP_SP2 after postback

D

Drew Berkemeyer

Hello,

We have an application that we have written using ASP.NET. On one of our
pages we open a popup window using javascript. The popup window has a save
and a cancel button. Both of them are server-side controls and do a
postback. While processing on the server we add javascript to the page load
(i.e. onload=window.opener.focus(); window.close()). However, the
window.close() command does not close the IE popup window.

This happens on both Internet and Local Intranet net zones.

We have tried adjusting the security settings all the way down to low and it
has no effect.

Can anyone help to shed some light on why this is not working.

Thank you in advance for your assistance.

Sincerely,
Drew Berkemeyer
 
C

Cirrosi

try window.opener.close().

I don't understand why you use a server side window instead of a simple
confirm in javascript.
 
S

Steven Cheng[MSFT]

Hi Drew,

As for the problem you mentioned, I've performed a simple test on my local
side. I use a XP Pro machine with SP2 installed and IE6. It seems that I
can close the popup window correctly via the script you provided. I'm
thinking there maybe something else which block the popup window from
closing. Is this problem occuring on many other machines on your side?
Anyway, here is the test pages I used, you may also have a try on your
side to see whether it'll return the same result:

============opener window===============
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<TR>
<TD><input type="button" value="popup"
onclick="window.open('popuppage.aspx');"/></TD>
</TR>
.................

==============popuppage.aspx=============
<HTML>
<HEAD>
<title>popuppage</title>
</HEAD>
<body runat="server" id="mybody">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 8px; POSITION:
absolute; TOP: 8px" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</HTML>


===========popuppage codebehind=========
private void Button1_Click(object sender, System.EventArgs e)
{
Page.RegisterStartupScript("closescript","<script
language='javascript'>window.opener.focus(); window.close();</script>");
}

If there is any othe new findings, please also feel free to post here.
Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
D

Drew Berkemeyer

OK. This is *very* similar to what we are doing.

I've created a new project that just includes the code you posted and it
works on my machine also. I will now try and narrow down the differences and
then post what I find.

*THANK YOU* very much for your timely response. It is greatly appreciated.

Sincerely,
Drew Berkemeyer
 
D

Drew Berkemeyer

OK. It's fixed.

Here was the problem:

Our orginal code had a syntax error that appearantly only shows up under XP
SP2 as we do not have any problems with any other OS.

The original code looked like this:
strScript += "window.opener.focus();"
strScript += "onload=window.close " ' Note the lack of parens and
semicolon
strScript += "</SCRIPT>"

When I changed it to match your example:
strScript += "window.opener.focus();"
strScript += "window.close();"
strScript += "</SCRIPT>"

It works like a champ!

Thank you again for all of your assistance. Your example gave me what I
needed to solve this quickly.

Sincerely,
Drew Berkemeyer
 
V

Vidar Petursson

S

Steven Cheng[MSFT]

Hi Drew,

Thanks for your followup. I'm also very glad that the problem has been
figured out and my suggestions are of assistance. Please feel free to post
here when you need our help. Have a good day!


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top