C# webbrowser NewWindow to Chrome Browser
(C# 웹브라우저 새창 열릴때 크롬브라우저로 실행방법)
If you click on a specific URL to open a new window, you will be able to receive the results from the Chrome browser.
(특정 URL을 클릭 하여 새창이 뜰 경우 크롬브라우저로 그 결과값을 받을 수 있도록 만드는 로직입니다.)
![[Solved] C# webbrowser NewWindow to Chrome Browser 2](https://vlog.tion.co.kr/wp-content/uploads/2018/09/448.png)
private void webBrowser1_NewWindow(object sender, System.ComponentModel.CancelEventArgs e)
{
HtmlElement htmlElement = webBrowser1.Document.ActiveElement;
string getUrl = htmlElement.GetAttribute("href");
if (getUrl.Equals(""))
{
e.Cancel = false;
return;
}
if (getUrl.StartsWith("//"))
{
}
else if (getUrl.StartsWith("/"))
getUrl = webBrowser1.Url.Host + System.Web.HttpUtitlity.UrlDecode(getUrl);
// Here you have the ready for navigation URL.
// chrome browser exec
Process process = new Process();
process.StartInfo.FileName = "chrome.exe";
process.StartInfo.Arguments = getUrl + " --new-window";
process.Start();