Question

A site I am working on displays an intermittent runtime error but only in IE7 and 8. This error will appear almost randomly (like, it may pop up on initial page load one time or it may not pop up until the nth page load). The error says it occurred at line:0 and the error is "Object required". I'm using jQuery throughout the site but disabling that in pieces (i.e. the various plugins and whatnot) has not solved the problem. I'm still cranking on it but want to get this "Help!" out on stackoverflow in case someone has dealt with something like this before.

The intermittency of it is what is really chapping my ass.

Was it helpful?

Solution

From your answer, I'd guess that the element with an id of 'header-section' is at the top of the page and, occasionally, the css rule is being applied before the rest of the page loads. This means that the expression tries to evaluate the offsetHeight of 'content-section' before that element exists.

I've a couple of suggestions about how to deal with this, but you would have to try them in order to evaluate their usefulness.

1/ Instead of making the rule based on the id of the 'header-section', make it based upon the class 'header-section. Don't add this class to the markup, but add it upon completion of document loading, via jquery - leave the id of the element as it is...

$(document).ready(function(){
  $("#header-section").addClass("header-section");
});

2/ Make the rule more tolerant of the 'content-section' not being found - not sure how often the expression is evaluated, as I've never felt the need to use expression in css rules, so this may not work.

#header-section {margin-top: expression((0 - (this.offsetHeight + (document.getElementById("content-section") ? document.getElementById("content-section").offsetHeight : 0))) + "px");}

Let me know how you get on.

P.S. I've no idea what the rule is trying to achieve - I mocked up a page with what I assume is the same layout, and all it does is move a lot of the content off the top of the page, in a way that prevents it from ever being seen.

OTHER TIPS

It seems like your script might be trying to access an object before the DOM has been fully created. Did you make sure you're function is inside the jQuery ready function?

   $(document).ready(function() {
          // put all your jQuery goodness in here.

   });

I figured it out. There are two expressions being used in an IE only css file. Here is one for example:

#header-section {margin-top: expression((0 - (this.offsetHeight + document.getElementById("content-section").offsetHeight)) + "px");}

Commenting out both instances that use these expressions solves the problem. Not sure why this happens exactly (and I didn't write the CSS that is doing this so I had no idea to even look in that CSS file).

It can't be a conflict with other JS because there were at least 2 places this was being used where no other JS was being loaded at all yet the error still occurred. Perhaps the IDs (content-section or header-section) could not be found for some reason? Not really sure... especially as the behavior was so inconsistent. Hmmm...

Thanks for the solution belugabob

I experienced the same error with Object required on line 0. Your fix with the expression ...?...:0 in the css for the ie stylesheet did the job.

The reason this kind of code is used, moving the navigation/headers up, is SEO related. You want your content on the top, and the less important SE wise navigation below it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top