首先要知道几个字符串,这几个字符串就类型命令行作用:根据需要使用
@"document.location.href"
@"self.location.href"
@"document.location"
@"top.location.href"
@"parent.document.location"
@"top.location.hostname"
@"location.hostname"
@"document.title" // 获取网页标题,可以做为网页识别标志
@"document.location.protocol"
@"document.location.port"
@"document.location.hash"
@"document.location.search"
@"document.location.pathname"
@"document.documentElement.innerHTML" // 获取全部网页文件
@"document.documentElement.innerText" //获取网页内容文字
@"document.body.innerText"
- (void)webViewDidFinishLoad:(UIWebView *)webView
{NSLog(@"url = %@",webView.request.URL); //
NSString *jshtml = @"document.documentElement.innerHTML";
NSString *jstitle = @"document.title";
NSString *jstext = @"thisURL = document.URL";
NSString *html =[webView stringByEvaluatingJavaScriptFromString:jshtml];
NSString *text = [webView stringByEvaluatingJavaScriptFromString:jstext];
NSString *htmltitle = [webView stringByEvaluatingJavaScriptFromString:jstitle];
- (void)webViewDidStartLoad:(UIWebView *)webView
{
// 可以根据执行的url 判断点击的位置,再实现OC 的相关操作
NSLog(@"正在执行的url= %@",webView.request.URL);
}