Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uwp close browser programmatically

Tags:

c#

uwp

I'm creating a simple news feed, it i want it can open the browser to show the details of the news, but i don't know how to close the browser , here is the code of how I open the browser,anyone can teach me how to off the browser using uwp? '

  public async void test()
{
      RootObject mynews = await NewsProxy.GetNews();
        string website = mynews.articles[i].url;
        var uriWeb = new Uri(websites);
        var success = await Windows.System.Launcher.LaunchUriAsync(uriWeb);
        if (success)
        {
            //Uri launched
        }
        else
        {
            // uri launch failed
        }



}
like image 569
j.doe Avatar asked Dec 06 '25 13:12

j.doe


1 Answers

var success = await Windows.System.Launcher.LaunchUriAsync(uriWeb);

Your code is actually telling the OS to Launch the given url and the OS in turn launches the default browser with the given URL. So you are not actually launching the browser.

In order to have full control over the browser behavior you can implement your own WebView and then use the url to navigate your WebView.

webView1.Navigate("http://www.contoso.com");

(MSDN Documentation for WebView)

like image 99
Pratyay Avatar answered Dec 09 '25 02:12

Pratyay