表单提交在Android 4.0中无效。相同的代码在较低版本的Android中运行良好。
查找我的参考代码
<form id="login-form" data-ajax="false" method="get" action="POST">
<div id="userPassLogin">
<div id="loginFormButtondiv" style="display: none;">
<a href="#" id="loginFormButton" style="font-size: small">Back to Login</a>
</div>
<div id="loginDiv">
<div data-role="fieldcontain" style="border: none; margin-top: 10px;">
<input style="width: 95%" type="email" class="placeholder" name="login" id="username" placeholder="Login ID" data-theme="c" value="Test286826.User286826@alere.com" />
</div>
<div data-role="fieldcontain" style="border: none; margin-top: 0px;">
<input style="width: 95%" type="password" class="placeholder" name="password" id="password" placeholder="Password" data-theme="c" value="P@ssw0rd" />
</div>
</form>
控制器代码是,
'submit #login-form' : 'onSubmit',
方法声明和定义是,
onSubmit : function(event)
{
alert('Inside the Form Submit');
if(isIOS){
nativeCommunication.callNativeMethod("networkcheck://isServerHosted?");
}
if(isAndroid || mHealth.util.webHostStatus){
alert('Inside the Form Submit');
event.preventDefault();
alert('Inside the Form Submit');
if(isAndroid){
alert('Inside the Form Submit');
this.doLogin();
}
}
},
任何帮助都会很棒。
由于
答案 0 :(得分:1)
我通过覆盖WebViewClient
修复了它 私有类MyWebViewClient扩展了WebViewClient { public String values = "";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("?")) {
try {
values = URLDecoder.decode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
url = url.replace("?", "%45");
String args[] = url.split("%45");
view.loadUrl(args[0]);
}else{
view.loadUrl(url);
}
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if(values.length()>0){
if(url.contains("page2.html")){
mWebView.loadUrl("javascript:getUrlVars(\""+values+"\");");
}
}
super.onPageFinished(view, url);
}
}