Fixed the double-firing IE bug. (Ticket #13)
[jquery.git] / event / event.js
index 5511b35..fcd590a 100644 (file)
@@ -46,17 +46,19 @@ $.$$ready = [];
 
 // Handle when the DOM is ready
 $.ready = function() {
-       $.$$isReady = true;
-       if ( $.$$ready ) {
-               for ( var i = 0; i < $.$$ready.length; i++ ) {
-                       $.apply( document, $.$$ready[i] );
+       if ( !$.$$isReady ) {
+               $.$$isReady = true;
+               if ( $.$$ready ) {
+                       for ( var i = 0; i < $.$$ready.length; i++ ) {
+                               $.apply( document, $.$$ready[i] );
+                       }
+                       $.$$ready = [];
                }
-               $.$$ready = [];
        }
 };
 
 // If Mozilla is used
-if ( $.browser == "mozilla" ) {
+if ( $.browser == "mozilla" || $.browser == "opera" ) {
        // Use the handy event callback
        document.addEventListener( "DOMContentLoaded", $.ready, null );
 
@@ -65,8 +67,8 @@ if ( $.browser == "mozilla" ) {
 } else if ( $.browser == "msie" ) {
 
        // Only works if you document.write() it
-       document.write('<script id="__ie_init" defer="true" ' + 
-               'src="javascript:void 0"><\/script>');
+       document.write('<scr' + 'ipt id=__ie_init defer=true ' + 
+               'src=javascript:void(0)><\/script>');
 
        // Use the defer script hack
        var script = document.getElementById('__ie_init');
@@ -79,10 +81,10 @@ if ( $.browser == "mozilla" ) {
        // Clear from memory
        script = null;
 
-// If Safari or Opera is used
-} else {
+// If Safari  is used
+} else if ( $.browser == "safari" ) {
        $.$$timer = setInterval(function(){
-                if ( document.readyState == "loaded" || 
+       if ( document.readyState == "loaded" || 
                        document.readyState == "complete" ) {
 
                        clearInterval( $.$$timer );