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.
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?
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.