#pragma mark-wknavigationdelegate iOS8
-(void) WebView: (Wkwebview *) WebView decidepolicyfornavigationaction: (wknavigationaction *) navigationaction Decisionhandler: (void (^) (wknavigationactionpolicy)) Decisionhandler {
-webview:shouldstartloadwithrequest:navigationtype similar to UIWebView:
NSString *url = [navigationAction.request.URL.absoluteString stringbyreplacingpercentescapesusingencoding: Nsutf8stringencoding];
Decisionhandler (Wknavigationactionpolicyallow);
if ([URL iscontainsubstring:@ "Tel:"]) {
[[UIApplication sharedapplication] Openurl:[nsurl Urlwithstring:url]];
}
}
Or
-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (nsurlrequest *) Request Navigationtype: ( Uiwebviewnavigationtype) Navigationtype
In this method, when navigationtype = = uiwebviewnavigationtypelinkclicked
Get the URL of str by [[Request URL]absolutestring] and then
[WebView loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@ "Tel:xxxx"]]
Get the phone number in webview and dial