Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:在webview中使用javascript单击没有id或类的链接_Javascript_Android_Class_Click - Fatal编程技术网

Android:在webview中使用javascript单击没有id或类的链接

Android:在webview中使用javascript单击没有id或类的链接,javascript,android,class,click,Javascript,Android,Class,Click,我需要执行一个特定的链接点击。不幸的是,我无法控制html页面,我所拥有的是: <table width="10%" height="44px" cellspacing="0px" border="0" padding="0px"> <tbody> <tr> <td> <a href="https://www.example.com/test"> <img border="0" src="https://www.example.c

我需要执行一个特定的链接点击。不幸的是,我无法控制html页面,我所拥有的是:

<table width="10%" height="44px" cellspacing="0px" border="0" padding="0px">
<tbody>
<tr>
<td>
<a href="https://www.example.com/test">
<img border="0" src="https://www.example.com/images/img.png">
</a>
</td>
<td>
<a href="https://www.example.com/test2">
<img border="0" src="https://www.example.com/images/img2.png">
</a>
</td>
</tr>
</tbody>
</table>
我得到这个错误:

未捕获类型错误:document.getElementsById不是函数


问题是您不能对自身重复调用
getElementsByTagName()
——该函数返回元素的
HTMLCollection
,并且
getElementsByTagName()
函数不能再次应用于该函数

一种替代方法可以是:

document.getElementsByTagName('table')[0].childNodes[0].childNodes[x].childNodes[y].click()
document.getElementsByTagName('table')[0].childNodes[0].childNodes[x].childNodes[y].click()