Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 2.49 KB

webuiview.md

File metadata and controls

40 lines (27 loc) · 2.49 KB
-api-id -api-type ms.custom
T:Windows.UI.WebUI.WebUIView
winrt class
RS5

Windows.UI.WebUI.WebUIView

-description

Represents a view (window) of the app to the application background script.

-remarks

Windows 10 web apps support an optional per-application background script that starts before any views are activated and runs for the duration of the process. With this, you can monitor and modify navigations, track state across navigations, monitor navigation errors, and run code before views are activated.

When this background script is specified as the StartPage in your app manifest, each of the app's views (windows) are exposed to the script as instances of the WebUIView class, providing the same events, properties, and methods as a general (Win32) WebView.

There are several differences between the HTML webview (x-ms-webview/MSHTMLWebViewElement) and the WebUIView class:

  HTML webview WebUIView class
WebUIView async methods Return MSWebViewAsyncOperation objects Return JavaScript promise objects
Navigate method Requires a URI in the form of a string Requires a Windows.Foundation.Uri object
InvokeScriptAsync method Script arguments are specified as an arbitrary number of string parameters Script arguments are specified as an array of strings

Any app activation with the background script as the StartPage will rely on the script itself for navigation.

-see-also

-examples

Your app can listen for the NewWebUIViewCreated event to intercept control of the navigation for a new view (exposed from NewWebUIEventCreatedEventArgs.WebUIView):

Windows.UI.WebUI.WebUIApplication.addEventListener("newwebuiviewcreated", newWebUIViewCreatedEventHandler);