IE6 ASP.NET error from document.onload: 'this.events' is null

View: New views
2 Messages — Rating Filter:   Alert me  

IE6 ASP.NET error from document.onload: 'this.events' is null

by Nicko Cadell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In IE 6 I am getting the following error when the page loads.

---------------------------
Error
---------------------------
A Runtime Error has occurred.
Do you wish to Debug?

Line: 913
Error: 'this.events' is null or not an object
---------------------------
Yes   No  
---------------------------

This does not occur in FireFox, only in IE (6).
I am using ASP.NET and I believe that this is caused by an interaction
between jQuery and the way ASP.NET hooks the document onload event.

To fix this issue I have added a test for this.events in the jQuery
event handle function. This appears to resolve the problem and the
jQuery ready event handlers are still run correctly.

handle: function(event) {
        if ( typeof jQuery == "undefined" ) return;

        event = event || jQuery.event.fix( window.event );

        // If no correct event was found, fail
        if ( !event ) return;

        var returnValue = true;

        if (this.events) // *** Added this test ***
        {
                var c = this.events[event.type];
       
                for ( var j in c ) {
                        if ( c[j].apply( this, [event] ) === false ) {
                                event.preventDefault();
                                event.stopPropagation();
                                returnValue = false;
                        }
                }
        }
       
        return returnValue;
},

Hope this helps anyone else who runs into this issue.

Cheers,
Nicko

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: IE6 ASP.NET error from document.onload: 'this.events' is null

by Jörn Zaefferer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nicko Cadell schrieb:

> In IE 6 I am getting the following error when the page loads.
>
> ---------------------------
> Error
> ---------------------------
> A Runtime Error has occurred.
> Do you wish to Debug?
>
> Line: 913
> Error: 'this.events' is null or not an object
> ---------------------------
> Yes   No  
> ---------------------------
>
> This does not occur in FireFox, only in IE (6).
> I am using ASP.NET and I believe that this is caused by an interaction
> between jQuery and the way ASP.NET hooks the document onload event.
>
> To fix this issue I have added a test for this.events in the jQuery
> event handle function. This appears to resolve the problem and the
> jQuery ready event handlers are still run correctly.
>  
That seems to be more of a workaround then a solution. Could you provide
a testpage where the problem occurs (without your fix applied)?

-- Jörn

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/