Created
March 29, 2016 12:13
-
-
Save lihei12345/134610249b33af887202 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler | |
| { | |
| WKNavigationActionPolicy policy = WKNavigationActionPolicyAllow; | |
| BOOL isFragmentJump = NO; | |
| if (navigationAction.request.URL.fragment) { | |
| NSString *nonFragmentURL = [navigationAction.request.URL wm_nonFragmentURLString]; | |
| isFragmentJump = [nonFragmentURL isEqualToString:webView.URL.absoluteString]; | |
| } | |
| if (!isFragmentJump) { | |
| BOOL should = [_webViewDelegate wmWebView:self shouldStartLoadWithRequest:navigationAction.request]; | |
| if (!should) { | |
| decisionHandler(WKNavigationActionPolicyCancel); | |
| return; | |
| } | |
| } | |
| if ((policy == WKNavigationActionPolicyAllow) && !isFragmentJump && [navigationAction.request.URL wm_isHTTPOrFileURL]) { | |
| _lastRequest = [navigationAction.request mutableCopy]; | |
| } | |
| decisionHandler(policy); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment