UIWebView:如何在HTML文本字段中插入文本 [英] UIWebView: How to insert text in a HTML text field

查看:121
本文介绍了UIWebView:如何在HTML文本字段中插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于加载移动网络表单网址的 UIWebView 。在我的应用程序中的一个方法中,我想在具有焦点的UIWebView的HTML文本字段中插入一些文本。

I've an UIWebView where a mobile web form URL is loaded. In a method in my application, I would like to insert some text into the HTML text field in the UIWebView which has focus.

我该如何做?有没有办法获得具有焦点的HTML元素的ID,我可以使用JavaScript将文本插入到这个元素?

How can I do that? Is there a way to get the ID of the HTML element which has focus -- than I can insert the text into this element using JavaScript?

推荐答案

这是一个JavaScript问题,因为我的解决方案是使用jQuery调用 $(*:focus)更改所选元素的值在 UIWebView 中。这显然需要在 UIWebView 中加载的网页使用 jQuery 。调用是使用 -stringByEvaluatingJavaScriptFromString:作为 Sixten Otto 描述的。

This turns out being a JavaScript question, as my solution was to use the jQuery call $("*:focus") to change the value of the selected element in the UIWebView. This obviously requires that the page loaded in the UIWebView is using jQuery. The call was made using -stringByEvaluatingJavaScriptFromString: as Sixten Otto describes.

这篇关于UIWebView:如何在HTML文本字段中插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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