Android 4.0及以上版本中的表单提交问题



Form Submit在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();
        }
    }
},

任何帮助都会很棒。

感谢

我通过覆盖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);
    }
}

最新更新