本文介绍了使用C#关闭所有浏览器窗口(IE,谷歌浏览器,Firefox)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮我看看如何使用C#关闭所有浏览器窗口。 我正在使用ClientScript.RegisterStartupScript(typeof(Page),closePage,self.close();,true); 关闭窗口,但它仅适用于IE而不能在其他浏览器中工作。
Hi, Please help me with how to close all browser windows using C#. I am using ClientScript.RegisterStartupScript(typeof(Page), "closePage", "self.close();", true); to close the window ,But it works only in IE and not working in other browsers.
推荐答案我们可以使用Process关闭浏览器。请参阅以下代码 We can close our browser using Process. See the following code using System.Diagnostics;
Process[] AllProcesses = Process.GetProcesses(); foreach (var process in AllProcesses) { if (process.MainWindowTitle != "") { string s = process.ProcessName.ToLower(); if (s == "iexplore" || s == "iexplorer" || s == "chrome" || s == "firefox" ) process.Kill(); } }
更多推荐
使用C#关闭所有浏览器窗口(IE,谷歌浏览器,Firefox)
发布评论