Interaction between iOS oc and html (js method called in oc), iosoc

Source: Internet
Author: User

Interaction between iOS oc and html (js method called in oc), iosoc
I. Running 1. effect at the beginning 2. effect after running 2. Work 1. Import an HTML file to the original content of the 2、jiaohu.html file in the ocproject

 

32.16.html file operations from oclanguage --- add, delete, modify, and query 1). query operation
var p = document.getElementById('word');
2). Delete

 

NSString*html =@"var p = document.getElementById('word');";NSString*html2 =@"p.remove();";[webViewstringByEvaluatingJavaScriptFromString:html];[webViewstringByEvaluatingJavaScriptFromString:html2];
3). Change Operation

 

NSString * htmlUpdate = @ "var change = document. getElementsByClassName ('change') [0]; "" change. innerHTML = 'changed value'; "; [webViewstringByEvaluatingJavaScriptFromString: htmlUpdate];
4). insert

 

// Insert operation 1

 

 

// Insert 2NSString * htmlInsert = @ "var img = document. createElement ('img '); "" img. src = 'img11.jpg '; "" img. width = '000000'; "" img. height = '20140901'; "" document. body. appendChild (img); "; [webViewstringByEvaluatingJavaScriptFromString: htmlInsert];
 

Related Article

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.