Last active
September 8, 2017 18:42
-
-
Save ardiwine/5c412b5ba56705d68ade to your computer and use it in GitHub Desktop.
Appcelerator Titanium: Open external link from a webview on a native browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webview = Ti.UI.createWebview({ | |
html: '[ PUT YOUR HTML HERE ]' | |
}) | |
webview.addEventListener('beforeload', function(e) { | |
if (e.url.toString().indexOf('http') != -1 || e.url.toString().indexOf('www') != -1) { | |
// you can also check for mailto:// | |
webview.stopLoading(true); | |
Ti.Platform.openURL(e.url); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great.