I am wanting to declare a var using data passed into the webview from TI.
.html file
Ti.App.addEventListener('ad_id',function(e) { var url_item = e.id; })Then later down the html.
<script type='text/javascript'> document.write('<div onclick="Ti.App.fireEvent(\'openURL\', { url: \'' + url_item + '\'}); return false;"></div>'); </script>How do i get the variable to pass to another function or a later call down the document?
1 Answer
Accepted Answer
You're code doesn't seem to make a lot of sense. You've got 2 events that have nothing to do with eachother and Im not sure if you're trying to set the var within the context of the webview or within the context of your Ti app. But if you want to try and get things set inside your already existing webview, you might try using the evalJS method on the webview. See the docs here: http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.UI.WebView-method-evalJS
This will allow you to execute some code, based on some value that you've already got in your Ti context.
Your Answer
Think you can help? Login to answer this question!