# SCRIPT5007: Unable to get property 'top' of undefined or null and too much recursion

**URL:** https://forum.kirupa.com/t/script5007-unable-to-get-property-top-of-undefined-or-null-and-too-much-recursion/331397
**Category:** web dev
**Created:** [July 23, 2013, 7:17pm UTC](https://forum.kirupa.com/t/script5007-unable-to-get-property-top-of-undefined-or-null-and-too-much-recursion/331397 "2013-07-23T19:17:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Keith\_Beeson](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@Keith\_Beeson](https://forum.kirupa.com/u/Keith_Beeson)
#### Post date: [July 23, 2013, 7:17pm UTC](https://forum.kirupa.com/t/script5007-unable-to-get-property-top-of-undefined-or-null-and-too-much-recursion/331397/1 "2013-07-23T19:17:57Z")

</div>

I am not sure about placing two questions into one post, but here it goes:

The error above “SCRIPT5007: Unable to get property ‘top’ of undefined or null” is coming from this function:

```
Code:

```

$(function () { //this is the way to run your code at the DOM Ready event $(‘a’).click(function () { $(‘html, body’).animate({ scrollTop: $($(this).attr(‘href’)).offset().top }, 1500); return false; }); });  
This is the effected code I believe that is causing the problem:

```
Code:

```

scrollTop: $($(this).attr(‘href’)).offset().top  
the error occurs when I click on a “clear” button in my form. My website is one long page and that function allows my navigation to slide up and down the site. Without it, everytime you click a nav, it jumps to that anchor.

For the 2nd problem, the too much recursion, the problem lies within here:

```
Code:

```

function () { if ($.isReady) return; imReady = true; $.each($.includeStates, function (url, state) { if (!state) return imReady = false }); if (imReady) { $.readyOld.apply($, arguments) } else { setTimeout(arguments.callee, 10) } }  
where the error is actually coming from the 2nd “function” script. This is part of the browser compatibility script for mozilla/opera at the top of the index page. Any help would be great. Thanks.
