title: Javascript in UIWebView
body: <p>I'm using UIWebView to display article and one of functionality requirements is text resizing. Since, setting increased size and reloading UIWebView loses scroll offset I decided use Javascript solution.</p>
  
  <p>Article HTML body tag looks like this: <code>&lt;body style='font-size:12px;'&gt;</code></p>
  
  <p>And resizing function basically looks like this:</p>
  
  <p><code>NSString * str;</code></p>
  
  <p><code>str = [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.fontSize=%d;", app.storyTextSize];</code></p>
  
  <p><code>[textView stringByEvaluatingJavaScriptFromString:str];</code></p>
  
  <p><code>[textView stringByEvaluatingJavaScriptFromString:str];</code></p>
  
  <p>And as a matter of fact it works. In my iPod it works great (double stringByEvaluatingJavascript does the trick), but I have reports from other tester that in his iPhone sometimes it works and sometimes it doesn't (I guess what he meant by that is that not every button click executes Javascript properly even if it should be executed twice for reassurance).</p>
  
  <p>Is there any way I could optimize my solution and make it more bullet proof? Or maybe there is a way to scroll back to previous position after reloading UIWebView, but, once again, setting offset in UIWebView will be Javascript bussiness..</p>