1

I'm trying again, because the last question didn't get any responses...

I have a form, which I'm filling out and committing in a webview with javascript injection, but I cant figure out how to click/submit the form..

i have tried all of the un-commented functions without any luck.

public void navigateToScheduleWebPage() throws IOException {



            webView.loadUrl("javascript:(function(){ " + "document.getElementsByName('aarskort')[0].value=201506426;" + "})()");

            // webView.loadUrl("javascript:(function(){ " + "document.getElementsByTagName('input')[1].submit();" + "})()");

            //webView.loadUrl("javascript: {document.getElementsTagName('form')[0].submit();}");

            /*  webView.loadUrl("javascript:(function(){"+
                "doc=document.getElementsByName('B1')[0];"+
                "event=document.createEvent('HTMLEvents');"+
                "event.initEvent('click', true, true);"+
                "doc.dispatchEvent(event);"+
                "})()");

                */


        // call getScheduleAsync, all html included
        webView.loadUrl("javascript:HtmlViewer.getScheduleAsync" +
                "('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');");


    }

this is the structure of the webpage im trying to work with..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
 <head>
   <title>Skema</title>
   <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <script language="JavaScript"></script>
   <script>


   </script>

<LINK rel="stylesheet" type="text/css" href="/design/au.css">
<LINK rel="stylesheet" type="text/css" href="/design/js/aunoprint.css">

</head>


 <body >


  <FORM action="./ElevSkema.asp" method="post">
      Opslag for mine tilmeldinger - Indtast studienummer
      <INPUT style="WIDTH: 102px; HEIGHT: 22px" size=15 name=aarskort>
      <INPUT type=submit value=Søg name=B1>
  </FORM>



 </body>
</html>

Thanks in advance ! :)

Sudheesh R
  • 1,767
  • 3
  • 23
  • 43
  • Possible duplicate of https://stackoverflow.com/questions/24769555/in-android-how-can-i-set-the-value-of-a-edit-box-in-webview-using-javascript – Hemant Parmar Nov 14 '17 at 13:04
  • i have tried calling the js as functions, didnt work... :) –  Nov 14 '17 at 14:30

0 Answers0