0

I have a page that is quite jQuery reliant. The functionality on the page works fine in all browsers, except IE9. This I understand is down to the issue with IE9 where Javascript can load very slowly.

The problem I face is that the page, once loaded thinks that Javascript is not available.

An error I am seeing in the console is:

SCRIPT5007: Unable to get property 'length' of undefined or null reference
File: jquery-1.8.3.min.js, Line: 2, Column: 14331

For the record, the jQuery lib is loaded before any other js files.

I have tried to get around this issue by adding the following code into the head, to try and force IE9 into IE8 mode. Note by default for IE we force 'edge' mode.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--[if IE 9]>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <![endif]-->

However, this makes no difference.

Before anyone asks why we're relying on IE9, it is a business requirement.

Does anyone have any idea how I can get the page to render in IE8 mode if the bowser accessing the page is IE9?

Many thanks in advance.

I should add, the page in question has a 'noscript' check on it, so will not render if JS is not available. This is true ONLY in IE9. For all other browsers, the page will render fine. I'm wondering if the above error is something else...

For the record, I have been looking at this IE9 JavaScript error: SCRIPT5007: Unable to get value of the property 'ui': object is null or undefined thread.

Community
  • 1
  • 1
Keith
  • 1
  • 3

2 Answers2

0

As I understand it, this is an issue with jQuery under IE9, which was fixed at some point after jQuery 1.8.3.

So the issue can, in all probability, be fixed by using a later version of jQuery.

At this time, I would opt for jQuery 1.11.0. Don't be tempted by the 2.x series, which deliberately omits lots of backward compatibility stuff.

Unfortunately, this will mean requalifying everything that uses jQuery, which is a pain.

Roamer-1888
  • 19,138
  • 5
  • 33
  • 44
  • Sadly moving to 1.11 has not helped. Can you verify that the code I've used above to set IE8 compatibility is legit? (I'm not a js coder - Java is my area.) :) – Keith Oct 29 '14 at 14:22
  • I'm afraid I know no more about that IE8 compat' hack than it says in the link you provided in the question. When you tried jQuery 1.11.0, the hack was suppressed - yes? – Roamer-1888 Oct 29 '14 at 14:27
  • To be honest, I removed the hack completely, concerned more that a new jQuery lib would cause other issues. I needed to be sure base functionality remained intact, which sadly it did not. – Keith Oct 29 '14 at 15:05
  • Mmm, what a dilemma. Sorry, I'm out of ideas. – Roamer-1888 Oct 29 '14 at 16:09
  • Someone [here](https://forum.jquery.com/topic/script5007-unable-to-get-value-of-the-property-length-object-is-null-or-undefined) reported the same issue and tracked it down to an earlier version of jQuery overwriting the one he thought was loaded. – Roamer-1888 Oct 29 '14 at 16:33
  • ... Sorry, jQueryUI not jQuery itself – Roamer-1888 Oct 29 '14 at 16:41
0

OUr issue was down to IE not recognising the 'console' command. As we were running a number of console.log commands, when this part of the code was reached in IE9, it stopped, and prevented any other JS from loading.

So the fix we have implemented is: If console not defined (IE9), define an empty object literal

 if(!(window.console && console.log)) {
    console = {
        log: function(){},
        debug: function(){},
        info: function(){},
        warn: function(){},
        error: function(){}
    };
}    

This seems to be working for us now. :)

Keith
  • 1
  • 3