Use JS to get UIWebView loaded Web content

Source: Internet
Author: User

This article describes how to get the HTML content of a Web page by running javascript:

Get all html:nsstring *ljs = @ "Document.documentElement.innerHTML";
Get page title:nsstring *ljs2 = @ "Document.title";
UIWebView *lwebview = [self getcurrentwebview];
NSString *LHTML1 = [Lwebview Stringbyevaluatingjavascriptfromstring:ljs];
NSString *LHTML2 = [Lwebview stringbyevaluatingjavascriptfromstring:ljs2];

Implemented by means of the JavaScript implementation. More JavaScript methods are listed below:

JavaScript gets the current page URL, title, etc., how to use it to see yourself ~
Because this site uses pseudo-static, so get the document name, please [click here] and then run the code to see the full get, document.location.port; is to get the URL associated with the port number, Thishash = Document.location.hash; is to get the segment of the link property that follows the pound sign "#".

Thisurl = document. URL;

Thishref = Document.location.href;

Thissloc = Self.location.href;

Thisdloc = document.location;

Thistloc = Top.location.href;

Thisploc = parent.document.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.documentElement.innerHTML;

Thisbodytext = document.documentelement.innertext;//Get page content text
Thisbodytext = document.body.innertext;//Get page content text

Use JS to get UIWebView loaded Web content

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.