在UIWebView中设置文本字段的文本
我有一个UIWebView,我想将其中的一个文本字段设置为某些文本。 这甚至可能吗? 如果是这样,我该怎么做? 谢谢
是的,您可以使用JavaScript在UIWebView中设置文本字段的文本
作为一个例子,如果你有这种forms的文本框
<input id="textFieldID" type="text" value="TextValue"/>
设定值:
[theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value = 'Hello World'"]
获得价值:
NSString* value = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value"];