Search code examples
windows-store-appswinrt-xamlwindows-8.1

Windows Store App - Browser Control with script


We have a requirement to support the hosting of some third party HTML5 based UI in our Windows Store app.

The standard WebView control does not give us what we need. We need:

  • To allow script to execute a callback in the XAML page and get a return value
  • Call functions in the web page and get DOM objects back
  • Get the document Ready event

We are going to need this in a UWP app too


Solution

  • To allow script to execute a callback in the XAML page and get a return value

    Call functions in the web page and get DOM objects back

    The WebView has a InvokeScriptAsync(String, IIterable) method. You might be able to use this method with the JavaScript eval function to execute the specified script function from the currently loaded HTML, with specific arguments, and to use window.external.notify from the HTML event handler to notify the application using WebView.ScriptNotify event.

    Get the document Ready event

    You could choose the DOMContentLoaded and NavigationCompleted event.