Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
529 views
Welcome To Ask or Share your Answers For Others

1 Answer

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"/>

Setting value:

[theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value = 'Hello World'"]

Getting value:

NSString* value = [theWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('textFieldID').value"];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...