title: DOMContentLoaded event not firing
body: <p>I'm trying to detect when the DOM is ready using DOMContentLoaded.</p>
  
  <p>I'm injecting the following JavaScript code into a page:</p>
  
  <pre><code>var script = document.createElement('script');  
  script.type = 'text/javascript';  
  script.text = function addListener() {
      if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", DOMReady, false);
      }
  };
  
  function DOMReady() {
      document.location.href = "mydomain://anything.stuff";
  }
  
  function inject() {
      document.getElementsByTagName('head')[0].appendChild(script);
      addListener();
  }
  </code></pre>
  
  <p>It gets added by:</p>
  
  <pre><code>-(void)webViewDidFinishLoad:(UIWebView *)webView
  {
      static BOOL injected = NO;
      if (!injected)
      {
          NSBundle *bundle = [NSBundle mainBundle];
          NSURL *jsURL = [bundle URLForResource:@"DetectDOMLoaded" withExtension:@"js"];  
          NSData *jsData = [NSData dataWithContentsOfURL:jsURL];
          NSString *jsScriptAsString = [[NSMutableString alloc] initWithData:jsData encoding:NSUTF8StringEncoding];
          [self.webView stringByEvaluatingJavaScriptFromString:jsScriptAsString];
          [self.webView stringByEvaluatingJavaScriptFromString:@"inject();"];
          injected = YES;
      }
  </code></pre>
  
  <p>If I add alert calls I can see that the call to addEventListener is being successfully made. However the function DOMReady() is never called. Any ideas why not?</p>
  
  <p>Thanks</p>