form's onsubmit with UIWebView

时光怂恿深爱的人放手 提交于 2019-12-13 15:26:51

问题


I have this form:

<form id="form1" name="form1" method="post" action="#" onsubmit="window.open('http://www.google.com','Google','width=800,height=500,top=5000,left=6000,status=yes,resizable=yes,scrollbars=yes');">
<input type="submit" name="submit" onclick="doSubmit();" id="submit" value="Submit" />
</form>

And the javascript that belongs to it is:

<script type="text/javascript">
    function doSubmit () {
        form1.submit();
    }
</script>

When I test it in the native safari app all goes well and the onsubmit action opens a new tab, but when I test it in a UIWebView, the onsubmit isn't fired.

The form is submitted and registered in

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

and all methods are set to intercept popups with

[webView stringByEvaluatingJavaScriptFromString:@"window.open = function( inurl, blah, blah2 ) {  document.location = 'newTab:'+inurl; }"];

in the appropriate UIWebView delegate methods.

Any thoughts on why it isn't firing?

Thanks!

来源:https://stackoverflow.com/questions/12361439/forms-onsubmit-with-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!