title: highlight text in UIWebView
body: <p>I have UIWebView for displays HTML page articles. I need to search string or text and highlight. I referred this document <a href="http://www.icab.de/blog/2010/01/12/search-and-highlight-text-in-uiwebview/" rel="nofollow">http://www.icab.de/blog/2010/01/12/search-and-highlight-text-in-uiwebview/</a>. But nothing happen. </p>
  
  <pre><code> - (void)viewDidLoad
      {
     [wbCont loadHTMLString:webString baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  
  
      NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
      // getting an NSString
      NSString  *savedValue = [prefs stringForKey:@"got"];
  
      NSLog(@"saved is %@",savedValue);
  
      [self highlightAllOccurencesOfString:savedValue];
  
      [self.view addSubview:wbCont];
  
      [self.view setBackgroundColor:[UIColor grayColor]];
  
  
      }
  
     - (NSInteger)highlightAllOccurencesOfString:(NSString*)str
  {
      NSString *path = [[NSBundle mainBundle] pathForResource:@"UIWebViewSearch" ofType:@"js"];
      NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
  
      [wbCont stringByEvaluatingJavaScriptFromString:jsCode];
  
      NSString *startSearch = [NSString stringWithFormat:@"window.onload = function (){uiWebview_HighlightAllOccurencesOfString('%@')}",str];
      [wbCont stringByEvaluatingJavaScriptFromString:startSearch];
  
      NSString *result = [wbCont stringByEvaluatingJavaScriptFromString:@"uiWebview_SearchResultCount"];
      return [result integerValue];
  }
  </code></pre>