Android:Cisco默认身份验证 - 无法使用JavaScript单击按钮

时间:2017-10-26 11:27:05

标签: javascript android web authorization

早上好。

我正在尝试为员工(WiFi)实施自动授权。我已经完成了他们在领域的凭据,但我无法按下按钮。

Html页面来源:

<html>
<head>
    <title>Web Authentication</title>
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <style>
    //not important.
</STYLE>


<noscript>
    <meta HTTP-EQUIV="REFRESH" content="0; url=https://mydomain.ru/login_noscript.html">
</noscript>

<script language="javascript" src="/loginscript.js"></script>
<script>
    function getErrorMsgIfAny(){
        if(document.forms[0].err_flag.value == 1){
            document.writeln(' \
                <tr align="center"> <td colspan="2" style="color:#CC0000">Login Error.</td>\
                </tr><tr align="center"> <td width="350" class="message" colspan="2">The User Name and Password combination you have entered is invalid. Please try again.</td></tr>\
                <tr> <td class="caption" colspan="2">&nbsp;</td></tr>');
        }else{
            document.writeln(' ');
        }
    }

    function unhideform(){
        document.getElementById("formId").style.display = "block";
    }

</script>
</head>
<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
    <FORM method="post" ACTION="/login.html">
        <INPUT TYPE="hidden" NAME="buttonClicked" SIZE="16" MAXLENGTH="15" VALUE="0">
        <INPUT TYPE="hidden" NAME="err_flag" SIZE="16" MAXLENGTH="15" VALUE="0">
        <INPUT TYPE="hidden" NAME="err_msg" SIZE="32" MAXLENGTH="31" VALUE="">
        <INPUT TYPE="hidden" NAME="info_flag" SIZE="16" MAXLENGTH="15" VALUE="0">
        <INPUT TYPE="hidden" NAME="info_msg" SIZE="32" MAXLENGTH="31" VALUE="">
        <INPUT TYPE="hidden" NAME="redirect_url" SIZE="255" MAXLENGTH="255" VALUE="">
        <INPUT TYPE="hidden" NAME="network_name" SIZE="64" MAXLENGTH="64" VALUE="Guest Network">
        <div id="formId">
            <table border="0" cellspacing=0 cellpading="0" width="100%">
                <tr>
                    <td width="180" background="../../images/background_web41.jpg" align="middle" style="padding-bottom: 4px;" >

                        <h1>Login</h1>
                    </td>

                    <td height="53" align="right" style="padding-bottom: 4px; padding-right: 20px;" background="../../images/background_web41.jpg"><div align="right"><img src="../../images/cisco/cisco-webauth-logo-2007.gif" width="67" height="40"></div></td>

                </tr>
                <tr>
                    <td align="left" width="400">
                        <div class="content">
                            <table border="0" cellspacing="10" cellpadding="0">
                                <tr>
                                    <td>
                                        <table border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <th align="left" width="400">
                                                    Welcome
                                                </th>
                                            </tr>
                                            <tr>
                                                <td class="message" align="left" width="400">
                                                    You are connected to wireless network of South Ural State University. Please enter username and password provided to you.  
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <script>
                                    getErrorMsgIfAny();
                                </script>
                                <tr>
                                    <td>
                                        <table border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td width="100" nowrap>User Name</td>
                                                <td>
                                                    <INPUT type="TEXT" name="username" SIZE="25" MAXLENGTH="80" VALUE="">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td nowrap>Password</td>
                                                <td>
                                                    <INPUT type="Password" name="password" emweb_type=PASSWORD autocomplete="off" EMWEB_TYPE=PASSWORD onKeyPress="submitOnEnter(event);" SIZE="25" MAXLENGTH="127" VALUE="">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>&nbsp;</td>
                                                <td>
                                                    <script>getHtmlForButton("Submit","Submit","button","submitAction()"); </script>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                            </table>
                        </div>
                    </td>
                    <td align="right" >
                        <table border="0" cellspacing="10" cellpadding="0" >
                            <tr>
                                <td align="right" style="padding-top: 25px; padding-right: 20px;"
                                bgcolor="#ffffff" >
                                <div ></div></td>
                            </tr>
                        </table>   
                    </td>
                </tr>
            </table>
        </div>

        <div id="newLoginWebConsent" style="display:none; font-size:13px; font-family: 'CiscoSansThin, Helvetica Neue, Arial, Tahoma, sans-serif';">
            <p id="welcomeMsg" style="text-align: center; font-size:20px; margin-top: 25px;">
                Welcome to Guest Network
            </p>

            <div style="margin:30px 10px 30px 10px">
                <div id="content" style="border: 2px solid #bbbbbb; border-radius: 3px;  margin: 0 auto; padding: 10px; max-width: 600px;">
                    <div id="page1">
                        <p>
                            <span style="font-family:'CiscoSansThin';">Please agree to the terms of use and connect.</span><br/>
                            <INPUT type="checkbox" id="loginAccept" NAME="loginAccept" onchange="termsAccepted();" / >
                            I accept the <a href="#" onclick="show_terms_of_use();">terms of use</a>
                        </p>
                        <br/><br/>
                        <BUTTON class="tiny" type="button" id="loginConnectButton" onclick="submitAction();" disabled>
                            Connect
                        </button>
                    </div>
                    <div id="page2" style="display: none">
                        <p>
                            This service is intended for use by authorized guests at this facility. This is an open/unprotected wireless network. By using this service, guests understand and accept that it is their responsibility to protect their own computer while connected to this service, and irrevocably waive any right, cause or action, remedy or other claim against the host with respect to any damage that may be caused to a computer while it is using this network.
                        </p>
                        <br/><br/>
                        <BUTTON class="tiny" type="button" id="loginAcceptButton" onclick="show_accept_terms();">
                            Back
                        </button>
                    </div>
                </div>
            </div>

            <div style="text-align: center;">
                <img id="cisco_powered_logo"  src="images/cisco_powered_logo.png"/>
            </div>

        </div>
    </FORM>
    <script>

    </script>
</body>
<HEAD>
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
</HEAD>
</html>

我像这样评估JS(在onPageFinished()中):

String injectLogin = "javascript:document.getElementsByName('username')[0].value = '" + login + "';";
String injectPassword = "javascript:document.getElementsByName('password')[0].value = '" + password + "';";
String injectButtonPress = "javascript:document.getElementByName('Submit')[0].click;";

mWebView.evaluateJavascript(injectLogin, null);
mWebView.evaluateJavascript(injectPassword, null);
mWebView.evaluateJavascript(injectButtonPress, null);

我尝试了许多非常奇怪的东西,但无法让它发挥作用。提前谢谢。

0 个答案:

没有答案