views:

383

answers:

1

Hi, I am using this code to set the focus on textarea of HTML control using javascript in objective c. But its not working in UIWEBVIEW, while other code working for getting values of the html controls with same controls ID.

here the code: it is working

NSLog(@"m values %@",[webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('2txt').value"]);

it is not working:

[webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"2txt\").focus();"];

Any Idea,

Thanks,

A: 

When / from where are you executing the call to focus on the page element? If you're doing the focus first thing (as a UI setup when the page is loaded), are you first checking to make sure the page has loaded in its entirety? The element may simply not "be there" yet when you're trying to focus it.

This is purely a guess. :-)

Joshua Nozzi
I have checked the element is there and page is entirely loaded I am calling this code under this delegate method of WebView- (void)webViewDidFinishLoadUIWebView *)webView{}