当前位置:编程学习 > wap >>

iOS-获取当前网页的 url 和 title 和 html

[objc]  
@property (strong,nonatomic)UIWebView *webView;  
@property (strong,nonatomic)NSString *currentURL;  
@property (strong,nonatomic)NSString *currentTitle;  
@property (strong,nonatomic)NSString *currentHTML;  
[objc] view plaincopy
---------------------------------  
[objc]  
  
[objc]  
-(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 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,