Q:

How can I block the keyboard from appearing even though I need to set my webView contentEditable=true?

I am using a webView to display text content, and I am trying to use javascript to highlight text that the user selects. This becomes possible when contentEditable = yes, but that also brings up the keyboard whenever the user taps on any text.
How can I have the contentEditable = yes, but not have the keyboard show up so that the text is editable?
EDIT: Here is the code I am using to do the highlighting
- (void)highlight {
     NSString *currentColor = [webView stringByEvaluatingJavaScriptFromString:@"document.queryCommandValue('backColor')"];
     if ([currentColor isEqualToString:@"rgb(255, 255, 0)"]) {
         [webView stringByEvaluatingJavaScriptFromString:@"document.execCommand('backColor', false, 'white')"];
     } else {
         [webView stringByEvaluatingJavaScriptFromString:@"document.execCommand('backColor', false, 'yellow')"];
     }
}

I found it on this tutorial.

A:

So thanks to this post, I was able to come across a solution to this problem:
[self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('target').setAttribute('contentEditable','true')"];

if ([currentColor isEqualToString:@"rgb(255, 255, 0)"]) {
    [self.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand('backColor', false, 'white')"];
} else {
    [self.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand('backColor', false, 'yellow')"];
}

[self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('target').setAttribute('contentEditable','false')"];

I basically turn on editing only long enough to make a highlight in the webView, and then turn it back off right after I'm done. Probably not the most elegant solution, but the keyboard doesn't ever show up, and the highlighting works like a charm.

