Document Ready Problem.
Document Ready Problem.
Hi, people. I've got some "operation aborted" erros when using
jQuery's $( document ).ready(); function for wainting page to load and
after this, manipulating some HTML elements.
This problem occours both in IE 6 and 7. I've corrected it,
overwriting some functions right after importing jQuery. This is the
code I've used to fix this problem:
jQuery.ready = function(){
if ( !jQuery.isReady ){
jQuery.isReady = true;
if( jQuery.browser.msie ){
if( document.readyState != 4 && document.readyState != 'complete' )
{
jQuery.isReady = false;
document.onreadystatechange = function(){
if( document.readyState == 4 || document.readyState ==
'complete' ){
jQuery.ready();
};
};
return false;
};
};
if( jQuery.readyList ) {
jQuery.each(jQuery.readyList, function () {
this.apply( document );
});
jQuery.readyList = null;
};
if( jQuery.browser.mozilla || jQuery.browser.opera ){
document.removeEventListener( "DOMContentLoaded", jQuery.ready,
false );
};
if( !window.frames.length ){
jQuery( window ).load( function(){
jQuery("#__ie_init").remove();
});
};
};
};
jQuery.prototype.ready = function( f ){
if( jQuery.isReady ){
if( jQuery.browser.msie ){
if( document.readyState == 4 || document.readyState == 'complete' )
{
f.apply( document, [ jQuery ] );
}else{
document.onreadystatechange = function(){
if( document.readyState == 4 || document.readyState ==
'complete' ){
f.apply( document, [ jQuery ] );
};
};
};
}else{
f.apply( document, [ jQuery ] );
};
} else {
jQuery.readyList.push( function () {
return f.apply( this, [ jQuery ] );
} );
};
return this;
};
How you can see, It's just a little bit different of jQuery original
code.
Bye,
Rafael Martins