JavaScript runtime error: in IE only

0

Am getting an error when i run my site in IE (local host)

the error is as follows:

Unhandled exception at line 1440, column 9 in eval code

0x800a138f - JavaScript runtime error: Unable to get property 'top' of undefined or null reference

If there is a handler for this exception, the program may be safely continued.

This is the code it goes to:

 $window.scroll(function () {

if ($window.scrollTop() > offset.top) {

        $sidebar.stop().animate({
            marginTop: $window.scrollTop() - offset.top + topPadding
        });
    } else {
        $sidebar.stop().animate({
            marginTop: 0
        });
    }
});

the highlighted code is where it keeps hitting when i scroll on the page.

Am not sure why this is happening, has this happened to anyone? Or any ideas why its doing this.

Thanks

javascript
asked on Stack Overflow Mar 18, 2015 by ma32112345

2 Answers

0

It's all in the error message:

"Unable to get property 'top' of undefined or null reference"

That means that whatever you're trying to get top from, is undefined or null.
Specifically: offset is.

answered on Stack Overflow Mar 18, 2015 by Cerbrus
0

You might have got confused between offset.top with window.top
just review your code once again. And try replacing your 'offset.top' with 'window.top'

answered on Stack Overflow Mar 18, 2015 by Praveen • edited Mar 13, 2017 by Praveen

User contributions licensed under CC BY-SA 3.0