form's onsubmit with UIWebView

2019-07-15 14:02发布

问题:

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!