Hi, I uses iPad Air2, iPadOS 14.0 beta 4.
My app (ObjC) contains of WKWebView and loads the following html code with jquery (ver 1.11.1).
In iPadOS13, on click jquerySubmit button, my app calls objective-c method (webView:decidePolicyForNavigationAction:decisionHandler:) and executes javascript method (callback_test).
Then, it displays "callback: ok".
But, in iPadOS14, the following code does not work.
Could Apple fix this bug in iPadOS14 official release?
My app (ObjC) contains of WKWebView and loads the following html code with jquery (ver 1.11.1).
Code Block language html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script> <script> function f(){ var html = '<form name="myapi" action="myapi" method="POST">' + '</form>'; $(html).submit(); } function callback_test(option){ $('#temp').remove(); $('#callback').append('<div id="temp">callback: ' + option + '<div>'); } </script> </head> <body> <input type='button' onclick='f()' value='jquerySubmit'></input><br /> <div><div id='callback'></div></div> </body> </html>
In iPadOS13, on click jquerySubmit button, my app calls objective-c method (webView:decidePolicyForNavigationAction:decisionHandler:) and executes javascript method (callback_test).
Then, it displays "callback: ok".
But, in iPadOS14, the following code does not work.
Code Block language objective-c - (void) webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { NSMutableURLRequest* req = navigationAction.request.mutableCopy; if([navigationAction.request.HTTPMethod isEqualToString:@"POST"]) { NSURL *url = [req URL]; NSString *method = [url lastPathComponent]; if ([url isFileURL]) { if ([method isEqualToString:@"myapi"]) { [self.myWKWebView evaluateJavaScript:@"callback_test('ok')" completionHandler:nil]; } } } decisionHandler(WKNavigationActionPolicyAllow); }
Could Apple fix this bug in iPadOS14 official release?