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

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.