我的程序可以在网页中使用以下代码单击按钮本身:
public void onClick(View v) {
// TODO Auto-generated method stub
ourBrow.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
ourBrow.loadUrl("javascript:document.getElementById('G03').click()");
}
});
但是当我尝试在另一个网页上再次运行它时,我意识到Javascript中没有这样的document.getElementById('id')
。这是Javascript:
<table width="100%" cellspacing="0">
<tr>
<td width="18%" class="tableHeading">Career</td>
<td class="tableHeading">Program</td>
<td width="20%" class="tableHeading">Campus</td>
<td width="25%" class="tableHeading">Term</td>
<td width="15%" class="tableHeading"> </td>
</tr>
<tr class="rowSpacer">
<td></td>
</tr>
<tr class="rowLowlight">
<td class="data">Undergraduate</td>
<td class="data">3642 - Photo; </td>
<td class="data">KENS -Kens Campus</td>
<td class="data">2012</td>
<td class="data" align="right">
<input class="button" type="submit" title="Update Enrolment" name="bsdsSubmit-0" value="Update Enrolment">
</td>
</tr>
<tr>
<td class="rowSpacer" colspan="5"></td>
</tr>
<tr class="rowHighlight"><td
我只复制了按钮的Javascript,它太大了,无法在这里粘贴它们。在此代码中,我只知道:class="button" type="submit" title="Update Enrolment" name="bsdsSubmit-0"
。
答案 0 :(得分:2)
你必须使用这样的东西,
<input type="button" value="Update Enrolment" onclick="location.href='required url'" />