Javascript For HTML retrieval in Iphone UiWebView

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.