Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is it possibel to load Html code in webview with external browser? How can I do?

PsychoZeyarPsychoZeyar Member ✭✭✭
    var webData="<html><body>......</html>";
    var code = HttpUtility.HtmlDecode(webData);
        var htmlSource = new HtmlWebViewSource();
        htmlSource.Html = code;
        WebViwPage.Source = htmlSource;

Webview is like that.
I want to open this in external browser.

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai
    edited February 5

    We cannot load the html content in a browser directly, we need to pass the content to the broswer. Such as on Android, try to get the uri as an exernal stroage file to save the html string and then get the uri of the file. You could use Browser.OpenAsync method to open the browser with the uri.

    private void Btn_Clicked(object sender, System.EventArgs e)
    {
        var uri = DependencyService.Get<IFileUrl>().GetUri();
        Browser.OpenAsync(uri);
    }
    

    Related link:
    https://stackoverflow.com/questions/46407205/load-local-html-file-in-native-web-browser-in-xamarin-forms


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

Sign In or Register to comment.