Can't open a webView from a web page
Is it possible to create a new webView from a web page (by clicking an anchor tag.) I've been unsuccessful able to do that any help? I'll definitely appreciate
3 Answers
-
Haven't tried this before but something like this might work:
(in the webview, in a script tag)
function openPage(url) { Ti.App.fireEvent('openPage', url); return false; }
Then in the webview, in HTML you do something like this to call the function:
a href="http://www.google.com" onclick="openPage(this.href)"
Back in app.js you have to handle the event by adding an event listener:
Ti.App.addEventListener('openPage', function(url) { // put code here to open a new web view with the url });
Good luck and please post your answer if you get it working!
-
Beautiful, thank you so much!
-
I've tried the above example but can't get it to work. Could you post a working example?