javascript 如何关闭服务器端按钮单击中的当前选项卡?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20197918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 18:00:01 来源:igfitidea点击:
How to close the current tab in the server side button click?
提问by Anyname Donotcare
I try to close my current tab after confirm so i put the following code at the end of my confirm button , but the tab doesn't close !
我尝试在确认后关闭当前选项卡,因此我将以下代码放在确认按钮的末尾,但该选项卡没有关闭!
string jScript = "<script>close_window();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "keyClientBlock", jScript);
回答by Felipe Oriani
If you want to close the current window, you could try this:
如果你想关闭当前窗口,你可以试试这个:
string jScript = "<script>window.close();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "keyClientBlock", jScript);
回答by panky sharma
This might help
这可能有帮助
Response.Write("<script>parent.close_window();</script>");
回答by user3405179
I Just Add Following code on button.
我只是在按钮上添加以下代码。
OnClientClick="javascript:window.close();"