This article describes how to obtain the html content of a webpage by running javascript:
Obtain all html: NSString * lJs = @ "document.doc umentElement. innerHTML ";
Obtain the webpage title: NSString * lJs2 = @ "document. title ";
UIWebView * lWebView = [self getCurrentWebView];
NSString * lHtml1 = [lWebView stringByEvaluatingJavaScriptFromString: lJs];
NSString * lHtml2 = [lWebView stringByEvaluatingJavaScriptFromString: lJs2];
Use www.2cto.com to execute javascript. More javascript methods are listed below:
JavaScript obtains the URL and title of the current page. You can view the URL and title of the page ~
Because this site uses a pseudo static, so can not get the document name, please [click here http://www.staru.net/web/read.php? 57] Then run the code to view the complete information, document. location. port; is the port number associated with the URL, thisHash = document. location. hash is the segment after the # In the link property.
ThisURL = document. URL;
ThisHREF = document. location. href;
ThisSLoc = self. location. href;
ThisDLoc = document. location;
ThisTLoc = top. location. href;
ThisPLoc = parent.doc ument. location;
ThisTHost = top. location. hostname;
ThisHost = location. hostname;
ThisTitle = document. title;
ThisProtocol = document. location. protocol;
ThisPort = document. location. port;
ThisHash = document. location. hash;
ThisSearch = document. location. search;
ThisPathname = document. location. pathname;
ThisHtml = document.doc umentElement. innerHTML;
ThisBodyText = document.doc umentElement. innerText; // obtain the webpage content text
ThisBodyText = document. body. innerText; // obtain the text of the webpage content.
From happy Program