我们如何在c#中关闭浏览器的选项卡 [英] how can we close the tab of a browser in c#
本文介绍了我们如何在c#中关闭浏览器的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Team i am just open a tab with java script in c#
//here
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.open('");
sb.Append(url);
Session["url"] = url.ToString();
sb.Append("');");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(),
"script", sb.ToString());
//this is f9 perfactly ...
and i want to close the open tab(url) after 40 seconds
how it possible
i am using
string jScript = "<script>window.close();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "btnsubmit", jScript);
//this work with btnsubmit on any other form
but here is not working ..
i am just want to perform it with timer event or any other option you have please suggest..
推荐答案
你做错了。您已经使用window.open
。此调用返回您放弃的窗口对象。但你可以使用它:
You are doing it wrong. You already usewindow.open
. This call returns window object which you discard. But you can use it:
var someWindow = window.open(/* ... */);
// ...
someWindow.close();
做吧在Javascript中作为页面脚本的一部分:
Do it in Javascript as part of the page script:
setTimeout("window.close()",40000);
应该这样做
这篇关于我们如何在c#中关闭浏览器的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文