ios - 将文本注入 UIWebView textField [英] ios - Injecting text into a UIWebView textField

查看:21
本文介绍了ios - 将文本注入 UIWebView textField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题 - 如果网络表单中的文本字段不会自动设置由表单设置的焦点,即您必须在键盘弹出之前按下该字段 - 我假设该字段无法编辑是否正确?

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?

换句话说 - 我无法通过向 textField 中注入 javascript 来为它设置文本,除非它专注于加载网站,对吗?

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

干杯

推荐答案

是的,你可以!您可以使用 Javascript 来设置值:

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

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

这是一篇文章,向您展示了如何设置和获取使用 Javascript 的文本字段的值.

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

希望这有帮助!

这篇关于ios - 将文本注入 UIWebView textField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆