Created
September 14, 2012 12:12
-
-
Save aaronksaunders/3721583 to your computer and use it in GitHub Desktop.
handling links in a webview
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
## jQuery [plain_text] | |
Make sure you make a reference to the jQuery library in the header of your HTML. Also remember that you must load the HTML into the WebView from a local file. | |
## This event definition goes in you app.js [javascript] | |
Ti.App.addEventListener('openBrowser',function(e){ | |
Ti.Platform.openURL(e.URL); | |
}); | |
## This JQuery goes in the HTML file [javascript] | |
$(document).ready(function(){ | |
$('a').each(function(){ | |
$(this).bind('click',function(){ | |
var theURL=this.getAttribute('href'); | |
var eventObject = new Object; | |
var a = 'URL'; | |
eventObject[a] = theURL; | |
// Fire Titanium Event to Open the URL in a new Window | |
Ti.App.fireEvent('openBrowser',eventObject); | |
return false; | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment