iOS获取webView的内容等(JS交互)
2016-06-09 22:52
603 查看
1.在.h文件定义
@property (strong,nonatomic)UIWebView *webView; @property (strong,nonatomic)NSString *currentURL; @property (strong,nonatomic)NSString *currentTitle; @property (strong,nonatomic)NSString *currentHTML;2.在.m文件执行
-(void) webViewDidFinishLoad:(UIWebView *)webView { [UIApplicationsharedApplication].networkActivityIndicatorVisible =NO; self.title = [webViewstringByEvaluatingJavaScriptFromString:@"document.title"];//获取当前页面的title self.currentURL = webView.request.URL.absoluteString; NSLog(@"title-%@--url-%@--",self.title,self.currentURL); NSString *lJs = @"document.documentElement.innerHTML";//获取当前网页的html self.currentHTML = [webView stringByEvaluatingJavaScriptFromString:lJs]; }
相关文章推荐
- iOS 限制输入字数完美解决方案
- iOS 人脸识别功能
- iOS-简单抽屉效果实现
- IOS xib封装自定义view 的封装步骤
- IOS开发收集整理(经典)
- IOS音频变成之变声处理
- 使用Azure notification hub推送消息到xamarin手机应用
- IOS7笔记-8、协议、block、动画
- iOS 取消图片渲染
- 自定义iOS7导航栏背景,标题和返回按钮文字颜色
- iOS高仿:花田小憩3.0.1
- ios开发笔记之十二 --viewDidload的方法的基本介绍用代码设置按钮的属性
- iOS跳转到系统的设置界面(支持iOS10)
- iOS开发中的本地数据存储(持久化)
- iOS应用发布篇二(开发者账号购买)
- iOS笔记之NSSet
- iOS应用发布篇一(开发者账号申请)
- IOS开发中的实用技术使用注意点
- ios切图规范
- 文件枚举