Reputation: 15866
I want show an information page after success db opartions. And after the info I want to close each pages (information page and main page)
I wrote this in button oncommand event:
//but this code does not work
Response.Write("<script language='javascript'>setTimeout('self.close();',3000);</script>");
at the same time, I want to show an information message. And then I want to close all, after three seconds.I hope I could explain :)
Thanks.
Upvotes: 1
Views: 1131
Reputation: 15866
I solve the problem And It works with all browser.
here is code :
String MyScript = "";
MyScript += "<script language='javascript'>";
MyScript += " window.open('', '_self', '');";
MyScript += " top.window.close();";
MyScript += "</script>";
Page.ClientScript.RegisterClientScriptBlock(GetType(), "PopupClose", MyScript);
Upvotes: 1
Reputation: 17724
Firefox would only allow window.close(); and only if you opened the window with a script.
Refer: window.close
When this method is called, the referenced window is closed.
This method is only allowed to be called for windows that were opened by a script using the window.open method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.
Upvotes: 2