jkally
jkally

Reputation: 814

How should a view controller interact with a UIWebView

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?

Upvotes: 0

Views: 430

Answers (1)

Sharjeel Aziz
Sharjeel Aziz

Reputation: 8535

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);

Upvotes: 1

Related Questions