Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

android webView does not care about evalJS, all versions-works fine on ios

$
0
0

Hi there, i'm trying to listen to some buttons inside a webview, that, when pressed, should change a counter inside the App, for this i use this code

var linkJS = 'document.titaniumLinkQueue = [];'
               + '(function(){' + 'var links = document.getElementsByTagName("a");'
                    + 'for(var i = 0, l = links.length; i < l; i++) {'
                    + 'var h = links[i].attributes["href"];'
                     +'debug.log("webview url : " + h);'
                    + 'h.value = "javascript:document.titaniumLinkQueue.push(\'" + h.value + "\');"'
                   + '}'
               + '})();';
when the webview has loaded and i navigated to another page it should asked if it is correct page and inject the script
// snip from 'loaded' eventlistener
 if (isAddress == 0) {
            www.evalJS(linkJS);
            // and 3 times a second, check to see if any links have been clicked
            setInterval(self.pollClickedLinks, 333);
            //no we don't want that to go on forever....
            win.addEventListener('close', function() {
                clearInterval(x);
            });
        }
//snip end
the polling function:

self.pollClickedLinks = function() { var link = www.evalJS('document.titaniumLinkQueue &amp;&amp; document.titaniumLinkQueue.pop();'); if (link==&quot;#tb_gemerkt&quot;) { Ti.App.fireEvent('merkenClicked', { href : link }); }; 

all this doesn't seem to be a problem in itself, it works on ios 5 / 6 but not on any androids i have for testing (2.3.3 ,4.1.1, 4.0.3)

the only Messages the Debugger has spit out were:

[INFO][TiWebChromeClient.console( 5878)] (main) [94,101493] detected smartphone portrait; set input width to 210 (249:http://[...]application/helpers/debug.js?1370966372117) [WARN][TiWebViewBinding( 5878)] (KrollRuntimeThread) [1299,102792] Timeout waiting to evaluate JS

and this, but this is put out even before the App launches...

[WARN][WebViewProxy( 3305)] (KrollRuntimeThread) [10679,61735] WebView not available, returning null for evalJS result.

could anyone help me decipher what's wrong, please?


Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>