I am using javascript to open a new window and close the existing window. To close the existing window I am adding the following at the bottom of the page <script>Window.close();</script>
This is all working fine but IE asked me if I am sure that I want to close the window before it opens the new window. How do i get rid of this message?
Thanks in Advance.
Sinner_G
1:18 pm on Jul 15, 2003 (gmt 0)
AFAIK, you don't get rid of it. It is built in the browser and there's no way around.
moonbiter
1:22 pm on Jul 15, 2003 (gmt 0)
Sinner_G is remembers correctly. This is a security feature built into javascript itself: a script cannot close a browser window without user input unless it opened the window itself. This prevents a piece of evil code from closing a user's browser window without their consent.
BlobFisk
1:23 pm on Jul 15, 2003 (gmt 0)
Apologies - didn't read the original post correctly first time.
<edit>Post removed due to posters inability to read correctly!</edit>
Red_Eye
1:46 pm on Jul 15, 2003 (gmt 0)
Thanks you have answered my question. very quickly I must say.
I am not trying to execute some melicous code. It is following a login screen, the user enters a secure area so I am opening a new window with the toolbars removed. It is more of a web appication than a web site.
krieves
3:47 pm on Jul 15, 2003 (gmt 0)
This should work. Add this script to the child window to close the parent without having a dialog box appear. Works in IE...
if (!opener.closed && opener.location){ opener.location.href="index.htm"; opener.opener = top opener.parent.window.close(); }