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

c++ - C/pp Sockets, recv()/send() works only under gdb -

GO: Serve static pages -

objective c - How to open front/back camera at the same time in iOS developing? -