I'm trying to achieve a relatively simple result - focus on a textBox when page is loaded. I use this code:
[_webView setKeyboardDisplayRequiresUserAction:NO];
NSString *javaString = [NSString stringWithFormat:@"document.getElementById('keyboard').focus()"];
NSString *result = [_webView stringByEvaluatingJavaScriptFromString:javaString];
It's called by a button click in my app. This code worked on the test page, but doesn't work on the actual site. The worst part is that I don't know any way to debug this.
Nothing happens and result is always empty string. How do I check if there's an error in JS code? Or it can't find the object? Or it can't focus on it?
UPDATE
As rightly noted by @subzero, I forgot the actual focus() method in the question. It's correct now.