Close browser window without prompt
Hi all,
I'm using the following javascript to close a browser window:
Code:
Response.Write("<script language='javascript'> { window.close();}</script>")
It works good but I get the confirmation prompt. Is there a way I can modify the above syntax so it closes the browser window without the confirmation prompt? I'm using VS 2008 and ASP.NET 2.0
Thanks,
Strick
Re: Close browser window without prompt
If you did a forum search you'd come across this solution posted by Mendhak a little under one month ago. It should work but it's evil. EVIL!
Re: Close browser window without prompt
Hello,
Thank you for you response. I still get the prompt even when using the code from the post you provided. Here is how I'm using it:
Code:
Response.Write("<script language='javascript'> { window.opener='blah';window.close();}</script>")
Thanks,
Strick
Re: Close browser window without prompt
Not sure then as it's something I've never fiddled with. I'm sure Mendhak will come across this post and help with his own code though, heh.
I always thought the opener being the same as the parent would allow you to close it but his code goes the other way so I'm not sure.
Re: Close browser window without prompt
Hm.. it works for me. What browser you used? I used in this context:
HyperLink1.NavigateUrl = "javascript:window.opener='blah';window.close();";
Re: Close browser window without prompt
Hi, Using IE7. Haven't tried it on IE6 yet? Also I'm using the response.write to execute the javascript in my code (the code I'm using is in my previous post) so I don't have to assign it to a hyperlink. My code works, but it's still prompting to close the window. But if I have to use a hyperlink to do it I guess thats the way I'll have to go. I'll try that this evening when I get home and let you know.
Thanks for your help.
Strick
Re: Close browser window without prompt
Remove the curly braces. They mean nothing if it's not in a function.
Re: Close browser window without prompt
PS: Yes, quite evil. What have I unleashed!
Re: Close browser window without prompt
Quote:
Originally Posted by mendhak
Remove the curly braces. They mean nothing if it's not in a function.
The curly braces just define a block and not necessarily a function ;).
Re: Close browser window without prompt
Re: Close browser window without prompt
Quote:
Originally Posted by
stricknyn
Hi, Using IE7. Haven't tried it on IE6 yet? Also I'm using the response.write to execute the javascript in my code (the code I'm using is in my previous post) so I don't have to assign it to a hyperlink. My code works, but it's still prompting to close the window. But if I have to use a hyperlink to do it I guess thats the way I'll have to go. I'll try that this evening when I get home and let you know.
Thanks for your help.
Strick
For IE7 you can use this:
window.open('', '_self', '');
window.close();