title: Can't get jQuery to load in IE8 or IE9
body: <p>I have a header that runs off a js file which can be included on other people's sites, however in IE8 and IE9, I get:</p>
  
  <blockquote>
    <p>'$' is undefined</p>
  </blockquote>
  
  <p>in the console.</p>
  
  <p>My code only utilizes jQuery if it is IE8 or IE9 because of cross domain issues which are taken care of with the built in functions in the jQuery library.  When browsing on WordPress sites the included script works fine, but on another site without jQuery loaded beforehand, it does not work, and the code I use to include jQuery in the header before loading the jQuery code also does not work.</p>
  
  <pre><code>var isIE = getInternetExplorerVersion();
  if (isIE == 8 || isIE == 9) {
  
    // Insert jQuery &lt;script&gt; to &lt;head&gt;.
    var head = document.getElementsByTagName( 'head' )[0], script;
    script = document.createElement( 'script' );
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
    head.insertBefore( script, head.lastChild );
  
    // Run jQuery test
    $('html').click(function(){
      // Runs without issue on sites that ALREADY have jQuery loaded when IN IE.
      alert('Clicked while in IE');
    });
  
  } else {
     // Runs without issue when not on IE.
     alert('Not in IE');
  }
  </code></pre>
  
  <p>For those wondering, this is the function for figuring out the IE version (irrelevant in this case as it works):</p>
  
  <pre><code>function getInternetExplorerVersion() {
      var rv = -1; // Return value assumes failure.
      if (navigator.appName == 'Microsoft Internet Explorer');
      {
          var ua = navigator.userAgent;
          var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  
          if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 );
      }
      return rv;
  }
  </code></pre>