Reputation: 1289
My program works to click a button itself with the following code in a web page:
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()");
}
});
But when I try to run it again in another web page, I realized there is no such document.getElementById('id')
in the Javascript. Here is the 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
I only copied the Javascript of the button, it was too huge to paste all them here. In this code, I only know: class="button" type="submit" title="Update Enrolment" name="bsdsSubmit-0"
.
Upvotes: 0
Views: 1003
Reputation: 8471
You have to use something like this,
<input type="button" value="Update Enrolment" onclick="location.href='required url'" />
Upvotes: 2