我在解析WebView HTML或加載URL(相對或絕對)時沒有任何問題,但我很難理解如何以編程方式「模擬」用戶輸入用戶名&密碼,然後單擊提交/登錄按鈕,給出以下HTML:如何以編程方式在WebView中輸入表單輸入字段,然後單擊提交?
<form method="post" class="mobile-login-form" id="login_form" action="https://www.example.com/login.php?m=m&refsrc=http%3A%2F%2Fm.example.com%2F&refid=0">
<input type="hidden" name="lsd" autocomplete="off">
<input type="hidden" name="post_form_id" value="1b3cf017c90d483cc50fcac3f2a9a283">
<input type="hidden" name="charset_test" value="€,´,€,´,?,?,?">
<input type="hidden" name="version" value="1">
<input type="hidden" id="ajax" name="ajax" value="1">
<input type="hidden" id="width" name="width" value="313">
<input type="hidden" id="pxr" name="pxr" value="1.5">
<input type="hidden" id="gps" name="gps" value="1">
<div class="bgx msf" data-sigil="intfs">
<div class="mfss fcg">Username:
</div>
<input class="input mobile-login-field" name="username" value="" type="text">
</div>
<div class="bgx msf" data-sigil="intfs">
<div class="mfss fcg">Password:
</div>
<input class="input mobile-login-field" autocorrect="off" autocapitalize="off" name="pass" type="password">
</div>
<div class="bgx msf" data-sigil="intfs">
<label class="btn btnC touchable" data-sigil="blocking-touchable">
<input type="submit" value="Log In" class="mfss" name="login">
</label>
</div>
</form>
(我不控制HTML,這只是一個任意網站提示的例子)
我不需要做所謂的「沉默的認證」 - 我只是想爲用戶提供一個便捷的快捷方式來單擊一個按鈕,而不是重複輸入用戶名&密碼(如果是,則爲執行或clear data
)。
如何在android web瀏覽器中使用java腳本代碼? – user370305