开发者

How should a view controller interact with a UIWebView

开发者 https://www.devze.com 2023-01-06 06:33 出处:网络
Can a view controller interact with the HTML elements contained in a web page that\'s rendered by a UIWebView?Is there any开发者_开发知识库 access to the DOM, like there is in a C# form and a containe

Can a view controller interact with the HTML elements contained in a web page that's rendered by a UIWebView? Is there any开发者_开发知识库 access to the DOM, like there is in a C# form and a contained WebControl?


DOM API is not available. You can call a Javascript function from Objective-C by using stringByEvaluatingJavaScriptFromString.

To get the value of an input field named "fname":

NSString * fString =[webView stringByEvaluatingJavaScriptFromString:@"document.getElementByName(\"fname\").value"]; 
NSLog(@"fString: %@",fString);
0

精彩评论

暂无评论...
验证码 换一张
取 消