码迷,mamicode.com
首页 > Web开发 > 详细

wkwebview 和 JS 自用

时间:2016-08-12 13:29:08      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

 1 -(void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation{
 2     //获取 当前页URL
 3     NSString *js = @"document.location.href";
 4     [self.webView evaluateJavaScript:js completionHandler:^(id _Nullable response, NSError * _Nullable error) {
 5         NSLog(@"response: %@", response);
 6     }];
 7     
 8 }
 9 
10 //这个调用只能放在 finish 里,不然会报JS 异常
11 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
12     NSString *js = @"headHide()";
13     [self.webView evaluateJavaScript:js completionHandler:^(id _Nullable response, NSError * _Nullable error) {
14         NSLog(@"\n error: %@", error);
15     }];
16 
17 }

 

wkwebview 和 JS 自用

标签:

原文地址:http://www.cnblogs.com/-yun/p/5764378.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!