简体   繁体   中英

Load URL(button) in WebView with JavaScript

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">&nbsp;</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" .

你必须使用这样的东西,

<input type="button" value="Update Enrolment" onclick="location.href='required url'" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM