JQuery and IE8

Having purchased “JQuery Novice to Ninja” I set about trying out the examples from your dowload section. I was pleasantly surprised to see all working as described in the book until I tried them on Internet Explorer 8, where none of them work.

I’ve checked the internet for people with problems with IE8 and have found several, has anyone here seen any fixes?

My initial thoughts are to throw the book and do something in PHP or the like but that’s not the answer, anyone else have problems even getting a simple alert box to display (chapter 2)?

Has anybody got any of the examples from the book to run under IE8?

Yes indeed.

Please show us all of the code you are using for the simple alert box example and we’ll see where we can help.

I have cut and paste the code into this window - hope this helps, thanks. This example is one of the many that go with the book and are downloadable from the sitepoint site.

++++++++++++++++++++++++++++++++
INDEX.HTML
++++++++++++++++++++++++++++++++
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”/>
<title>StarTrackr!</title>

<link rel=“stylesheet” href=“…/…/css/base.css” type=“text/css” media=“screen” charset=“utf-8” />
<script src=“…/…/lib/jquery-1.4.min.js” type=“text/javascript” charset=“utf-8”></script>
<script type=“text/javascript” src=“script.js”></script>
</head>
<body>
<div id=“container”>
<div id=“header”>
<h1>StarTrackr!</h1>
</div>
<div id=“content”>
<h2>
Welcome!
</h2>
<div id=“navigation”>
<ul>
<li><a href=“#”>Home</a></li>
<li><a href=“#”>Buy Now!</a></li>
<li><a href=“#”>About Us</a></li>
<li><a href=“#”>Gift Ideas</a></li>
</ul>
</div>
<p id=“intro”>
Welcome to <strong>StarTrackr!</strong> the planet’s premier celebrity tracking and monitoring service. Need to know where in the world the best bands, musicians or producers are within 2.2 square meters? You’ve come to the right place. We have a very special special on B-grade celebs this week, so hurry in!
</p>
<p id=“disclaimer”>
Disclaimer! This service is not intended for the those with criminal intent. Celebrities are kind of like people so their privacy should be respected.
</p>

  &lt;div id="news"&gt;
    &lt;h2&gt;Latest News&lt;/h2&gt;
    &lt;p&gt;
      Which member of the seminal calypso/lectro band &lt;em&gt;C&amp;C Music Sweatshop&lt;/em&gt; was spotted last night at &lt;em&gt;Dirt&lt;/em&gt;, the trendy New York restaurant that serves only food caught and retrieved by the chef's own hands?
      &lt;span class="spoiler"&gt;Yes! It's the ever-effervescent, &lt;em&gt;Glendatronix&lt;/em&gt;!&lt;/span&gt;
    &lt;/p&gt;
    &lt;p&gt;Who lost their recording contract today? &lt;span class="spoiler"&gt;The Zaxntines!&lt;/span&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="celebs"&gt;
    &lt;h2 class="heading"&gt;Our Celebrities&lt;/h2&gt;
    &lt;p class="info"&gt;
      We have an ever changing roster of newly chipped celebrities. But it can take as little as a week for the little critters to realise they've been tagged - so you have to be fast! 
    &lt;/p&gt;
    &lt;table class="data"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;ID&lt;/th&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Occupation&lt;/th&gt;
          &lt;th&gt;Approx. Location&lt;/th&gt;
          &lt;th&gt;Price&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;203A&lt;/td&gt;
          &lt;td&gt;Johny Stardust (&lt;a href="bio.pdf"&gt;bio&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;Front-man&lt;/td&gt;
          &lt;td&gt;Los Angeles&lt;/td&gt;
          &lt;td&gt;$39.95&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;141B&lt;/td&gt;
          &lt;td&gt;Beau Dandy (&lt;a href="img.jpg"&gt;pic&lt;/a&gt;,&lt;a href="bio.pdf"&gt;bio&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;Singer&lt;/td&gt;
          &lt;td&gt;New York&lt;/td&gt;
          &lt;td&gt;$39.95&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;2031&lt;/td&gt;
          &lt;td&gt;Mo' Fat (&lt;a href="img.jpg"&gt;pic&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;Producer&lt;/td&gt;
          &lt;td&gt;New York&lt;/td&gt;
          &lt;td&gt;$19.95&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;007F&lt;/td&gt;
          &lt;td&gt;Kellie Kelly (&lt;a href="bio.pdf"&gt;bio&lt;/a&gt;,&lt;a href="w.doc"&gt;press&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;Singer&lt;/td&gt;
          &lt;td&gt;Omaha&lt;/td&gt;
          &lt;td&gt;$11.95&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;8A05&lt;/td&gt;
          &lt;td&gt;Darth Fader (&lt;a href="img.jpg"&gt;pic&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;DJ&lt;/td&gt;
          &lt;td&gt;London&lt;/td&gt;
          &lt;td&gt;$19.95&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;6636&lt;/td&gt;
          &lt;td&gt;Glendatronix  (&lt;a href="bio.pdf"&gt;bio&lt;/a&gt;,&lt;a href="w.doc"&gt;press&lt;/a&gt;)&lt;/td&gt;
          &lt;td&gt;Keytarist&lt;/td&gt;
          &lt;td&gt;London&lt;/td&gt;
          &lt;td&gt;$39.95&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div id="comment"&gt;
    &lt;h2&gt;Leave a comment&lt;/h2&gt;
    name:&lt;br /&gt;
    &lt;input type="text" /&gt;&lt;br/&gt;
    comment:&lt;br/&gt;
    &lt;textarea rows="5" cols="30" name="comment"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  
  &lt;h2&gt;Fine Print&lt;/h2&gt;
  &lt;p id="fine_print"&gt;
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.    
  &lt;/p&gt;
  
&lt;/div&gt;

&lt;div id="footer"&gt;
  &lt;p&gt;
    &copy; Copyright 2010 CelebriTracker Productions
  &lt;/p&gt;
&lt;/div&gt;

</div>
</body>
</html>

++++++++++++++++++++++++++++++++
SCRIPT.JS
++++++++++++++++++++++++++++++++
$(document).ready(function(){
alert(‘Welcome to StarTrackr! Now no longer under police investigation!’);
});

++++++++++++++++++++++++++++++++
…/…/css/base.css
++++++++++++++++++++++++++++++++
#navigation{
float: right;
width: 150px;
}
#intro{
width: 450px;
}

body {
font-family: “Lucida Sans Unicode”,“Lucida Grande”,Sans-Serif;
color: #3E3E3E;
background: #94C5EB url(…/images/background-grad.png) repeat-x;
font-size: 12px;
}

p {
padding: 5px;
}

a {
color: #3687AF;
}

#container{
margin:0 auto;
text-align: left;
width: 650px;
}

#header{
height: 60px;
color: #172322;
background: transparent url(…/images/header-corners.png) no-repeat bottom left;
}

#header h1
{
padding:0;
margin:0;
}

Content{
background-color: #fff;
padding: 0 15px 10px 15px;

}

#footer{
background-color: #fff;
padding:15px;
clear: both;
}

h2 {
border-bottom:2px solid #015287;
color: #D15600;
padding-top: 10px;
margin-top: 0;
}

table {
border-collapse:collapse;
font-size:12px;
margin:0 20px 20px 20px;
border-top:2px solid #015287;
width:480px;
}

th {
border-bottom: 2px solid #015287;
color: #D15600;
font-size: 14px;
font-weight: normal;
text-align: left;
padding: 3px 8px;
}

td {
padding: 6px;
}

Here’s a silly question.

Do you find that IE8 show a yellow bar along the top of the non-working web page?

Like you I have come across this bug using the same book as you but most of the examples in the early pages work in ie8 for me. The first problem I came across was on page 52 regarding the animate function. I know it’s been reported to the jquery team but no solution is available yet - hopefully it will be fixed in the next version release.

@Mick - the original poster is quite likely to be facing a more fundamental problem, because none of the examples appear to be working for him on Internet Explorer.

Thanks for posting though.

Sorry for the delay in replying.

I didn’t say that I was running Windows 7, not sure if that makes a difference…

The yellow bar appeared initially but I have set the internet advanced options to allow active content to run, now I get everything except the alert in the code supplied. Strange that it should run on Firefox 3.6 straight out of the box.

My guess, there is a delay while loading the JQuery framework and the script.js is actually loading before the Jquery finishes so it doesn’t fire.

Try moving the jquery.js to the same directory and see if it works.

Else try setTimeOut to delay the alert for 2-3 seconds.

You could also call a function at the bottom of your html page that kicks off a script.

Tx for all your suggestions, its great that people try help.

Moving the script into the same directory doesn’t work, neither does setTimeOut (I set it from 2 up to 20 seconds).

Whatever is preventing the JQuery code working is a mystery, time to rethink what language I use.

Thanks all the same…

Bryan

I think you are giving up too easily…jquery is ideal and works well for most and in most setups (temporary (hopefully) ie8 bug aside). There must be something ‘odd’ with your local system…have you tried on a different computer?

Odd, you’re absolutely right. I have also a Samsung NC10 netbook, XP Home Lite and IE8 and FireFox - hey presto, it works on both browsers - the difference is the machine it doesn’t run on is running Windows 7.

Giving up too easily, maybe… I have long gone past the days where I wanted to know what that did and how this interacts with that, I’m a humble end-user who wants the computer to do something thats all…

Windows 7 has nothing to do with the error, sounds like you need to make some adjustments in the browser itself (settings). Maybe JS is turned off. Good Luck

The browser settings are identical between the Windows 7 PC and Samsung netbook

What happens with the following test code?


<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("a").click(function(event){
            alert("Thanks for visiting!");
        });
    });
    </script>
  </head>
  <body>
    <a href="http://jquery.com/">jQuery</a>
  </body>
</html>

Hey presto! It works!!!

Are you saying the document isn’t ready?

Show us your code. :headbang:

The code is as you asked me to type in - am I missing something here?

Yes, I am interested in the non-working code.