admin管理员组

文章数量:1332389

Quick question - if a textfield in a webform, does not automatically has the focus set by the form, ie you got to press the field before the keyboard pops up - am I correct to assume that field cannot be edited then?

In other words - I cannot set a text for a textField by injecting javascript into it, unless it gets a focus upon loading of the website right?

NOTE: I am not talking about set texts or placeholders here:-)

Cheers

Quick question - if a textfield in a webform, does not automatically has the focus set by the form, ie you got to press the field before the keyboard pops up - am I correct to assume that field cannot be edited then?

In other words - I cannot set a text for a textField by injecting javascript into it, unless it gets a focus upon loading of the website right?

NOTE: I am not talking about set texts or placeholders here:-)

Cheers

Share asked May 8, 2012 at 19:57 jwknzjwknz 6,82417 gold badges76 silver badges117 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

Yes you can! You can use Javascript to set the value:

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

Here's an article which shows you how to set and get the values of textfields with Javascript.

Hope this helped!

本文标签: javascriptiosInjecting text into a UIWebView textFieldStack Overflow