JS window.close() let IE hang

Posted by p4bl0.666 on Stack Overflow See other posts from Stack Overflow or by p4bl0.666
Published on 2010-05-26T09:06:52Z Indexed on 2010/05/26 9:11 UTC
Read the original article Hit count: 176

Hi all,

for reason I won't bore you with, I'm writing an asp.net application that must open some pages in new browser windows.

I managed to open them within a postback (don't ask why, I just needed to) with this code:

script = String.Format(@"window.open(""{0}"", ""{1}"");", url, target);
ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);

Now I have new windows each one with a button that should close it. I have simply an onclick="window.close()" (but that prompts me when I'm closing the browser) or window.open('','_self','');window.close() (horrible, I agree but it's the only way I found to avoid the JS prompt)

On firefox it works perfectly but on IE7 (the browser our customers have) after 2-3 times I use that button to close the window I can't open other windows (in both cases, with or without the JS prompt). With the method above it does nothing, and with a <a href="mypage.aspx" target="_blank">click me</a> a new window is opened but hangs on loading (it doesn't even calls the Page_Load).

What could be the cause? How can I solve this?

Thank you.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript