Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marchbold/7249d3b069af5f7255d8 to your computer and use it in GitHub Desktop.
Save marchbold/7249d3b069af5f7255d8 to your computer and use it in GitHub Desktop.
Handling and intercepting location change events in a WebView
// Here we assume you have previously initialised the extension
var webView:WebView = NativeWebView.service.createWebView( new Rectangle( 0, 0, 400, 600 ) ) ;
webView.addEventListener( NativeWebViewEvent.LOCATION_CHANGING, webView_locationChangingHandler );
webView.addEventListener( NativeWebViewEvent.LOCATION_CHANGE, webView_locationChangeHandler );
webView.loadURL( "http://airnativeextensions.com" );
...
private function webView_locationChangingHandler( event:NativeWebViewEvent ):void
{
trace( "location changing to: " + event.data );
// Stop the location change by calling 'event.preventDefault()'
event.preventDefault();
}
private function webView_locationChangeHandler( event:NativeWebViewEvent ):void
{
trace( "location changed to: " + event.data );
}
// com.distriqt.NativeWebView
@marchbold
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment