使用C#中的给定URL关闭现有浏览器窗口
问题描述:
我有一个控制台应用程序,该应用程序使用给定的URL打开浏览器窗口.我要在启动新的浏览器窗口之前关闭具有给定URL的所有现有浏览器窗口.
请帮帮我!
I have a console application which opens the browser window with given URL. I want to close all the existing browser window with given URL before launch the new browser window.
Please help me!!
答
我不知道您能否做到这一点-大多数现代浏览器不会在可用位置显示URL您可以在不检查每个特定浏览器的情况下阅读和比较.例如,Chrome不会在标签上显示网址,而只会在地址栏中显示该网址,甚至不需要显示该网址.而且AFAIK没有通用命令从应用程序外部关闭通用浏览器的特定选项卡-只是关闭整个浏览器,这会将您的应用程序从硬盘上删除,因此数据位很快就会被擦伤!
您为什么认为这是个好主意?您要解决什么问题?
I don''t know if you can do exactly that - most modern browsers do not show the URL in an available location, or certainly one you could read and compare without checking for each specific browser. For example, Chrome does not show the URL on tabs, it only displays it in the address bar - which doesn''t even have to be visible. And AFAIK there is no generic command to close a particular tab of a generic browser from outside the application - just to close the whole browser which would get your application deleted from my hard disk so quickly the databits would get friction burns!
Why do you think this would be a good idea? What problem are you trying to solve?