在UIWebView中设置文本字段的文本 [英] Set text for a textfield in UIWebView
本文介绍了在UIWebView中设置文本字段的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UIWebView,我想将其中的一个文本字段设置为某些文本。这是可能吗?如果是,我该怎么办呢?
感谢
I have a UIWebView and I want to set one of it's text field to certain text. Is that even possible? If so, how can I do that? Thanks
推荐答案
是的,您可以使用javascript在UIWebView中设置文本字段的文本
Yes you can set the text for a textfield in the UIWebView using javascript
例如,如果你有一个这种形式的文本框。
As an example if you have a textfield in this form
<input id="textFieldID" type="text" value="TextValue"/>
设定值:
[theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value = 'Hello World'"]
获得价值:
NSString* value = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value"];
这篇关于在UIWebView中设置文本字段的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文