Created
May 30, 2016 09:05
-
-
Save kbshl/9fe7d992e5f98f38b4c801f1dcbe583b to your computer and use it in GitHub Desktop.
Appcelerator Titanium: Open link clicks from remote web view in system or other view
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
$.webView.addEventListener('beforeload', function(e) { | |
if ((OS_IOS && e.navigationType == Titanium.UI.iOS.WEBVIEW_NAVIGATIONTYPE_LINK_CLICKED) | |
|| (OS_ANDROID && e.url !== $.webView.getUrl())) { | |
// stop the event | |
e.bubble = false; | |
e.cancelBubble = true; | |
// stop the url from loading | |
$.webView.stopLoading(); | |
//opens up the clicked URL for bill in new webView | |
var link = e.url; | |
var args = {url: link}; | |
// open link in my default webView for iOS | |
var newWebView = Alloy.createController('defaultWebView', args).getView(); | |
newWebView.open(); | |
// or let the system open it | |
Ti.Platform.openURL(e.url); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment