Skip to main content
Ryan Price and the Media
Commanding Chaos for Coworking, Open Source and Creative Communities

Main navigation

  • Blog
  • About
  • Contact
  • Subscribe
  • Drupal Easy
  • Florida Creatives
  • Liberatr
  • Lifestream
  • ThinkUp
  • Home
User account menu
  • Log in

Breadcrumb

  1. Home
  2. JQuery Broken In Internet Explorer? Put Your $(document).ready At The Bottom!

jQuery broken in Internet Explorer? Put your $(document).ready at the bottom!

By rprice , 18 March 2008
Categories
HowTo
Coworking
Tech
Tags
javascript
jquery
Programming
Web Sites

i (not verified)

17 years 10 months ago

Thanks for posting this - it

Thanks for posting this - it helped me fix a similar problem i was having with IE6. Moving the $(document).ready() action to the bottom of the script worked for me too.

Peter (not verified)

17 years 9 months ago

I had this exact same problem

I had this exact same problem as well, and found this article most helpful in finding the solution.

However, I also discovered another solution and wanted to mention it for those who, for whatever reason, really need the dom ready script at the top. Instead of using the syntax:

$(document).ready(function() {...your code...})

You can use this syntax instead from the top of the page:

jQuery(function() {...your code...})

Thomas Staub (not verified)

17 years 8 months ago

Putting code at the end does

Putting code at the end does not ensure document is already ready. It might be most of the time, but notr always.
The suggestion of Peter is the correct solution. If you put your Code into $(document).ready() without sourronding function, it will be executed before document is ready. I made this mistake 100 times too.

Tonight at Cup-O-Code, David, Gabe and myself were troubleshooting a little issue with the product page javascript that Gabe uses to update the price as customers select various options. The code wasn't working in Internet Explorer, but since jQuery should be browser agnostic, we had to go back to the drawing board. After David re-wrote my first draft of the code we've got there, we got the function back to a working state in Firefox, but IE was still eluding us, but not really.

We were actually trying to make the script work on two instances of an online store, Futon Planet (FP) and Futons, Etc. (FE). The first site's product page was giving us no Internet Explorer trouble, but the second was behaving very strangely. Then we noticed that FE's javascript wasn't finding returning anything at all.

We used this code to help us debug and see if jQuery could find the value in question:
alert($("adjustedPrice").length());

Which returned a blank pop-up, when it should have been returning "$0.00" instead. The script didn't seem to be finding the value, and when the alert showed up, it was actually drawing the alert before you could actually see the rest of the page.

Apparently IE6 executes $(document).ready() at a different time or in a different fashion than Firefox, and once the javascript faults out it just stops everything.

We moved our $(document).ready() action to the bottom of the page, and everything was just fine after that.

Mission accomplished.

Twitter / liberatrRyan Price | Facebook Flickr: Photos from Liberatr.netInstagramYouTube :: Videos by liberatrLinkedIn: Ryan Price

I am nobody's puppet.

Disclaimer: My blogs are not a reflection of my employer's opinions, but are my own, and often unfiltered. Also, some links on this site may be part of an Amazon Associates program, so by clicking on them you help me pay for my independence.

Drupal Association - Individual Member Acquia Certified Developer Acquia Certified Developer Miro Video Player | Download torrents and podcasts, play any video, and do it with style. Gimp - a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. Processing is an electronic sketchbook for developing ideas. Build a custom arts management solution. LibreOffice is the free power-packed personal productivity suite that gives you six feature-rich applications for all your document production and data processing needs

  • Thanks again, Steve. I hope
    14 years 1 month ago
  • Hi - bit late responding here
    14 years 1 month ago
  • Should have added...
    14 years 2 months ago
  • Hi Ryan,
    14 years 2 months ago
  • Ryan,
    14 years 2 months ago
  • It is happening and you are
    14 years 5 months ago
  • In close future I want to
    14 years 8 months ago
  • the article has been
    14 years 9 months ago
  • I think it's a great coup for
    14 years 9 months ago
  • My hardware box acts as an
    14 years 10 months ago

  • Blogging Fringe
  • Bringing Art and Technology Together
  • Drupal Easy Podcast
  • Florida Creatives Podcast
  • Invisible Frisbee
  • Liberatr.net Facebook
  • Liberatr.net
  • Orlando Podcasters
  • Orlando Scene TV
  • Orlando Video
  • Our Yellow House
  • Pulpp.net Orlando Blogs
  • Pulpp.org Real-Time Collaboration
  • Shrink Your Ecological Footprint
  • The Student of the Game

  • Alex Rudloff
  • Apartment E
  • Brian Feldman
  • Chad Miller
  • Charles Krueger
  • Chris Messina
  • Chris Scott
  • Chris Wojda
  • Daniel H. Pink
  • Daniel Smith
  • Darren McDaniel
  • David Terrar
  • Destination Journal
  • Dr. XNLB
  • Elizabeth Maupin
  • Eric Marden
  • Hugh McLeod
  • Jana Waring
  • Jeremy Harrington
  • John Rife
  • Josh Hallet
  • Katie Ball
  • Katharine Miller
  • Lloyd Davis
  • Loren Feldman
  • marc. with a c.
  • Marc Rapp
  • Mario Andy Lurig
  • Mark Baratelli
  • Mike G
  • Noel Hidalgo
  • PSFK
  • Rebekah Lane
  • Stephen Matheny
  • Thomas Thorspecken
  • Tim Welch

  • Florida Drupal Group
  • Izon Orlando
  • Orlando Coworking
  • Orlando Fringe
  • Orlando Improv Festival
  • Orlando PHP
  • Orlando Puppet Festival
  • Page 15
  • The Daily City
  • Urban ReThink

Powered by Drupal

<none>

  • RSS Feed