title: How to inject JQuery into existing page within a UIWebView?
body: <p>I am trying to inject JQuery into a <code>UIWebView</code> of a page that I can't control, say Google, for example.  When a <code>UITextField</code> gets focus, I am executing the following lines of code:</p>
  
  <pre><code>NSString* scriptInject = @"var headElement = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); 
      script.setAttribute('src','http://jquery.com/src/jquery-latest.js');
      script.setAttribute('type','text/javascript'); headElement.appendChild(script);";
      [myWebView stringByEvaluatingJavaScriptFromString:scriptInject];    
      [myWebView stringByEvaluatingJavaScriptFromString:@"$(document).ready(function() {$('body').css('background', '#FF0000');}"];
  </code></pre>
  
  <p>I am executing the background change to validate that I am able to run a JQuery script.  I can verify that the Objective-C method is being called, and I even planted an <code>alert</code> for the onload of the newly created <code>&lt;script&gt;</code> tag, so I know that it is being executed in the <code>UIWebView</code>.  How do I inject it correctly that I can execute it?</p>
  
  <p>EDIT:</p>
  
  <p>I have event tried this after calling the function to change the color:</p>
  
  <pre><code>[myWebView stringByEvaluatingJavaScriptFromString:@"alert($('body').css());"];
  </code></pre>
  
  <p>No alert shows.</p>