Liam
Liam

Reputation: 9855

Strange Javascript quirk in IE 7/8

I have a sliding carousel on my page, when I visit my page in IE it doesnt work and instead the images that should be in the carousel are shwon in list format, as though my browser doesnt read the javascript for the selector and applying the effect.

This only happens in IE7/8 so far and when I view the source in firebug its as though my script tag is being closed by the browser before it has a chance to see the jQuery.

If I add a JS alert before my jQuery however, the alert pops up and then the jquery loads and so my carousel works.

<script type="text/javascript">

//This works with an alert, without it the browser renders <script type="text/javascript" />    
alert('test');

$(document).ready(function() {
    $('#seasonaloffers').carousel({
        start: 1
    });
    $('#newproducts').carousel({
        start: 1
    });
});
 </script>

Upvotes: 0

Views: 87

Answers (2)

Terry
Terry

Reputation: 14219

  1. Declare your <script> tags in the <head>
  2. Try adding <script type="text/javascript" language="javascript">
  3. Does it work in IE's compatibility mode or vice-versa?

Upvotes: 1

danp
danp

Reputation: 15251

Three things:

  1. Validate your html - http://validator.w3.org/
  2. Check you've not repeated that #id by mistake
  3. Use a strict/html5 doctype - http://ejohn.org/blog/html5-doctype/

Upvotes: 2

Related Questions