Monitoring and Canceling Navigation

The WebBrowser control allows in-place navigation. Users may click on a link to change the page displayed in the control, and in addition, client-side JavaScript may assign the window.location.href property to navigate to a new location, which requires that the WebBrowser.IsScriptEnabled property be set to true.

Allowing the user free rein over navigation may not always be desirable, and you may want to monitor or even cancel the navigation of a web page programmatically. Fortunately, the Navigating event of the WebBrowser can be canceled. This is done by subscription to the event in code, or in XAML as shown:

<phone:WebBrowser Navigating="webBrowser_Navigating"/>

When the WebBrowser begins navigating to a ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.