IOS: interaction between oc and html (js method called in oc), iosoc
I. Running
1. Initial Results
2. effect after running
2. Preparations
1. Prepare an html file and import it to the oc project.
2、original content of the jiaohu.html File
32.16.html file operations in oclanguage --- add, delete, modify, and query
1). query operations
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 operation 2
NSString * htmlInsert = @ "var img = document. createElement ('img ');"
"Img. src = 'img11.jpg ';"
"Img. width = '000000 ';"
"Img. height = '000000 ';"
"Document. body. appendChild (img );";
[WebViewstringByEvaluatingJavaScriptFromString: htmlInsert];