2012-09-11 34 views
0

表单提交在Android 4.0中不起作用。相同的代码在较低版本的Android中工作正常。表单在Android 4.0及更高版本中提交问题

找到我的代码供我们参考

<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="[email protected]" /> 
    </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="[email protected]" /> 
    </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(); 
     } 
    } 
}, 

任何帮助将是巨大的。

感谢

回答

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); 
    } 

} 
+0

如果ü请接受这个答案是有益的。它会对其他人有用。 – Ranjithkumar

+0

非常感谢您,但不幸的是,解决方案对我无效。我做了一些技巧来重新解决这个问题。 – Jabeer