********
#import "HMViewController.h"@interfaceHmviewcontroller () <UIWebViewDelegate>@end@implementationHmviewcontroller/** test.html exists in the server, the inside of the HTML and JS code, we can not modify if test.html display on the phone side, the UL removed*/- (void) viewdidload{[Super Viewdidload]; //1.webViewUIWebView *webview =[[UIWebView alloc] init]; Webview.frame=Self.view.bounds; WebView.Delegate=Self ; [Self.view Addsubview:webview]; Webview.scalespagetofit=YES; //2. Loading Web pagesNsurlrequest *request = [Nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://localhost:8080/MJServer/resources/htmls/test.html"]]; [WebView loadrequest:request];}#pragmamark-uiwebviewdelegate-(void) Webviewdidfinishload: (UIWebView *) webview{//use WebView to execute JS code and manipulate nodes in the Web pageNSString *JS1 =@"var ul = document.getelementsbytagname (' ul ') [0];"; NSString*JS2 =@"Ul.parentNode.removeChild (UL);"; [WebView STRINGBYEVALUATINGJAVASCRIPTFROMSTRING:JS1]; [WebView stringbyevaluatingjavascriptfromstring:js2];}@end
iOS web Seventh day Webview-01webview and Web page interaction 1