Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created September 14, 2012 12:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/3721583 to your computer and use it in GitHub Desktop.
Save aaronksaunders/3721583 to your computer and use it in GitHub Desktop.
handling links in a webview
## 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