I'm injecting a Javascript code in a webpage (opened in a webview) in order to let the app click on a URL link and open the page. I'm using the following code:
myBrowser.loadUrl("javascript:document.getElementsByTagName('a')[0].click();");
But it's not working; it's giving the following error: "Uncaught TypeError Object [object] has no method 'click' at null:1".
I can't understand where the problem is because i inject other Javascript in the same page (in another part of the code) through the getElementsByID("word").click() and it's correctly working.
I tried different user agents but nothing changed.
The target SDK is 14 and the minimum SDK is 9.
Someone told me that the .click() method is not supported by getElementsByTagName but it's not correct; i tried the same code on the "Try It Yourself editor" and it's correctly working.
Thanks for your support.