ios - Auto focus text field in UIWebview -


I am loading the webview form in my iOS app and I want to autofocus a textfield on the form. I tried

  NSString * focus = [NSString stringWithFormat: @ "document.getElementsByName ('j_captcha') [0]. Focus ()"]; [Self.webView stringByEvaluatingJavaScriptFromString: Focus];  

But it seems that there is no work to do. "J_captcha" is the name of the textfield. How can I get it?

This did the trick for me

  NSString * evalStr = [NSString StringWithFormat: @ "setTimeout (function () {document.getElementsByName ('j_captcha') [0]. Focus ();}, 1000);"]; [WebView stringByEvaluatingJavaScriptFromString: evalStr];  

This post got help -


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -