You can access web pages and web content in your application using the WebView functionality. You can also use various other features for Web browsing, such as loading and displaying web pages, and navigating through the browsing history.

The main features of WebView are as follows:


To enable your application to use WebView functionality:

  1. To use the Tizen.WebView namespace, create the ElmSharp-Beta project using the Project Wizard of Visual Studio.

  2. To use the class of the Tizen.WebView namespace, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

        <!--To use the Internet connection-->
        <!--To access media storage-->
        <!--To access, read, and write to the external storage-->
  3. To use the methods and properties of the Tizen.WebView namespace, include it in your application:

    using Tizen.WebView;

Initializing and Creating WebView

To Initialize WebView and create a WebView object, follow these steps:

  1. To use the Tizen.WebView namespace in your application, call the Tizen.WebView.Chromium.Initialize method before the start of the main loop:

    App app = new App();
  2. To create a WebView object, use the constructor of Tizen.WebView.WebView with ElmSharp.Window:

    var webView = new WebView(window)
        AlignmentX = -1,
        AlignmentY = -1,
        WeightX = 1,
        WeightY = 1

Managing Web Page Loading

To load a web page and add an event handler to loading events:

  • To load a web page, use the Tizen.WebView.WebView.LoadUrl method with an appropriate URL:

  • The following table lists the loading events provided by the Tizen.WebView.WebView class:

    Table: Loading Events

    Event Description Argument
    LoadStarted This event occurs when the page loading has started. -
    LoadFinished This event occurs when the page loading has completed. -
    LoadError This event occurs when the page loading has failed with an error. Tizen.WebView.SmartCallbackLoadErrorArgs
  • Add an event handler to handle each loading event:

    webView.LoadStarted += (s, e) =>
        /* Handle LoadStarted event here */
    webView.LoadFinished += (s, e) =>
        /* Handle LoadFinished event here */
    webView.LoadError += (s, e) =>
        /* Handle LoadError event here */
        // error code
        var code = e.Code;
        // description
        var desc = e.Description;
        // URL
        var url = e.Url;

To manage and set the cookie options, use the Tizen.WebView.CookieManager class.

  • To get the Tizen.WebView.CookieManager object from WebView, use Tizen.WebView.WebView.GetContext and Tizen.WebView.Context.GetCookieManager:

    CookieManager cookieManager = webView.GetContext().GetCookieManager();
  • To set the cookie acceptance policy, use the Tizen.WebView.CookieManager.SetCookieAcceptPolicy method:

    /* Accepts every cookie sent from any page */
    /* Rejects all the cookies */
    /* Accepts only cookies set by the main document that is loaded */
  • To set the persistent storage for the cookie, use the Tizen.WebView.CookieManager.SetPersistentStorage method:

    cookieManager.SetPersistentStorage(DirectoryInfo.Data, CookiePersistentStorage.SqlLite);

Executing JavaScript

To execute the JavaScript code, use the Tizen.WebView.Eval and Tizen.WebView.EvalAsync methods.

The following example shows the HTML file used:

    <div id="main" class="page">
        <div class="contents">
            <span id="content-text">Basic</span>
  • If you need a return value, use the Tizen.WebView.EvalAsync method:

    string result = await webView.EvalAsync("document.getElementById('content-text').innerHTML");
  • If you do not need a return value, use the Tizen.WebView.Eval method:

    webView.Eval("document.getElementById('content-text').innerHTML = 'Tizen'");

Finalizing WebView

To clean up the allocated resources, call the Tizen.WebView.Chromium.Shutdown method after the end of the main loop:

App app = new App();
  • Dependencies
    • Tizen 4.0 and Higher