title: Xamarin.Forms.WebView.Navigating event raised on iOS for internal navigation
body: <p>Let's say you want to prevent the user from navigating away from your Xamarin.Forms.WebView to an external page.</p>
  
  <pre><code>public App ()
  {
      var webView = new WebView
      {
          Source = new HtmlWebViewSource
          {
              Html = "&lt;h1&gt;Hello world&lt;/h1&gt;&lt;a href='http://example.com'&gt;Can't escape!&lt;/a&gt;&lt;iframe width='420' height='315' src='https://www.youtube.com/embed/oHg5SJYRHA0' frameborder='0' allowfullscreen&gt;&lt;/iframe&gt;"
          }
      };
      webView.Navigating += WebView_Navigating;
  
      MainPage = new ContentPage {
          Content = webView
      };
  }
  
  private void WebView_Navigating(object sender, WebNavigatingEventArgs e)
  {
      // we don't want to navigate away from our page
      // open it in a new page instead etc.
      e.Cancel = true;
  }
  </code></pre>
  
  <p>This works fine on Windows and Android. But on iOS, it doesn't load at all!</p>
  
  <p>On iOS, the Navigating event gets raised even when loading the source from a HtmlWebViewSource, with a URL that looks something like <code>file:///Users/[user]/Library/Developer/CoreSimulator/Devices/[deviceID]/data/Containers/Bundle/Application/[appID]/[appName].app/</code></p>
  
  <p>Alright, so you can get around that with something like this:</p>
  
  <pre><code>private void WebView_Navigating(object sender, WebNavigatingEventArgs e)
  {
      if (e.Url.StartsWith("file:") == false)
          e.Cancel = true;
  }
  </code></pre>
  
  <p>The page finally loads on iOS. Yay. But wait! The embedded YouTube video doesn't load! That's because the <strong>Navigating event gets raised for the internal navigation</strong> of embedded resources like iframes and even external scripts (like Twitter's <code>&lt;script charset="utf-8" type="text/javascript" src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt;</code>), but only on iOS!</p>
  
  <p>I couldn't find a way to determine if the Navigating event was raised from internal navigation or because the user clicked a link.</p>
  
  <p>How to get around this?</p>