44

My website works well on Chrome, Firefox, and Internet Explorer 8. But on Internet Explorer 9, very weird errors are triggered when just hovering over components.

SCRIPT5007: Unable to get value of the property 'ui': object is null or undefined ScriptResource.axd?d=sTHNYcjtEdStW2Igkk0K4NaRiBDytPljgMCYpqxV5NEZ1IEtx3DRHufMFtEMwoh2L3771sigGlR2bqlOxaiwXVEvePerLDCL0hFHHUFdTOM0o55K0&t=ffffffffd37cb3a1, line 181 character 1914

And following the link to the error in the javascript shows me these bits of code:

onNodeOver:function(B,A){A.ui.onOver(B)},onNodeOut:function(B,A){A.ui.onOut(B)}

I'm a little clueless on how to go about solving this error. I've seen this solution but that didn't solve the problem for me.

Any Ideas?

Carsten
  • 11,287
  • 7
  • 39
  • 62
Soroush Hakami
  • 5,226
  • 15
  • 66
  • 99
  • Many JavaScript libraries (especially non-recent ones) do not handle IE9 well because it breaks with IE8 in the handling of a lot of things. JS code that sniffs for IE will fail quite frequently in IE9, unless such code is rewritten to handle IE9 specifically. Before the JS code is updated, you should use the "X-UA-Compatible" meta tag to force your web page into IE8 mode. – Stephen Chung Apr 26 '11 at 07:54
  • Thanks alot, this solved my problem. Supply that comment as an answer and I will accept it. – Soroush Hakami Apr 26 '11 at 08:10

8 Answers8

149

Many JavaScript libraries (especially non-recent ones) do not handle IE9 well because it breaks with IE8 in the handling of a lot of things.

JS code that sniffs for IE will fail quite frequently in IE9, unless such code is rewritten to handle IE9 specifically.

Before the JS code is updated, you should use the "X-UA-Compatible" meta tag to force your web page into IE8 mode.

EDIT: Can't believe that, 3 years later and we're onto IE11, and there are still up-votes for this. :-) Many JS libraries should now at least support IE9 natively and most support IE10, so it is unlikely that you'll need the meta tag these days, unless you don't intend to upgrade your JS library. But beware that IE10 changes things regarding to cross-domain scripting and some CDN-based library code breaks. Check your library version. For example, Dojo 1.9 on the CDN will break on IE10, but 1.9.1 solves it.

EDIT 2: You REALLY need to get your acts together now. We are now in mid-2014!!! I am STILL getting up-votes for this! Revise your sites to get rid of old-IE hard-coded dependencies!

Sigh... If I had known that this would be by far my most popular answer, I'd probably have spent more time polishing it...

EDIT 3: It is now almost 2016. Upvotes still ticking up... I guess there are lots of legacy code out there... One day our programs will out-live us...

peterh
  • 11,875
  • 18
  • 85
  • 108
Stephen Chung
  • 14,497
  • 1
  • 35
  • 48
  • I had a webapp that worked locally in IE9 but when moved to the server I encountered the error in the original post. this fixed it! thanks! – RoboKozo Jun 17 '11 at 18:11
  • Yes, many sites are having issues with IE9 without forcing compatibility modes. Libraries seem to be the main culprit of these bugs, but at least we can force compatibility with minimal effort thanks to the X-UA-Compatible meta tag. Still, it doesn't really help when people, like myself, like to make sure everything works without having to run compatibility modes. Which means, people like myself must debug our scripts to see what it is IE9 is having issues with. Good thing is, after we've figured out common issues and bugs, writing future fully compatible scripts will be a walk in the park. – DoctorLouie Mar 13 '12 at 07:28
  • 1
    Ok, so how to update the js code so it works in IE9 other than setting that crappy meta tag? In some instances, setting the meta tag is not an option. – giorgio79 Sep 07 '12 at 11:16
  • 1
    Most JavaScript libraries have now been updated to support IE9+. Just upgrade to the latest version of your library, get rid of the meta tag and Bob's your uncle. – Stephen Chung Sep 12 '12 at 14:01
  • This is not quite right... You can't exactly force IE8 mode. See http://stackoverflow.com/questions/4811801/force-ie9-to-emulate-ie8-possible the result of this is IE7 mode, not IE8 mode as one intends. –  Oct 04 '12 at 19:25
  • _One day our programs will out-live us..._ Sad but true. – naXa stands with Ukraine Jan 21 '16 at 11:38
  • 1
    Best edit history I have found in Stackoverflow so far ))) – Chuck Norris Aug 11 '16 at 07:18
  • It is not exactly legacy code, it happens because of old computers/so that we have to support. For us, the IE9 userbase is high, insane, but a reality. – Edgar Jan 19 '17 at 18:16
  • Are you serious? You still maintaining IE8-specific code? I feel sorry for you... – Stephen Chung Sep 28 '18 at 03:43
14

I was having same issue in IE9. I followed the above answer and I added the line:

<meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" />

in my <head> and it worked.

TylerH
  • 20,799
  • 66
  • 75
  • 101
savan
  • 141
  • 1
  • 2
  • I am trying to include `exporting.src.js` in my jsp page, I have added `` tag inside ``, but the problem still persists in IE9. Can anyone please help? what should be done to avoid it? – Disera Apr 19 '16 at 11:29
5

I have written code that sniffs IE4 or greater and is currently functioning perfectly in sites for my company's clients, as well as my own personal sites.

Include the following enumerated constant and function variables into a javascript include file on your page...

//methods
var BrowserTypes = {
    Unknown: 0,
    FireFox: 1,
    Chrome: 2,
    Safari: 3,
    IE: 4,
    IE7: 5,
    IE8: 6,
    IE9: 7,
    IE10: 8,
    IE11: 8,
    IE12: 8
};

var Browser = function () {
    try {
        //declares
        var type;
        var version;
        var sVersion;

        //process
        switch (navigator.appName.toLowerCase()) {
            case "microsoft internet explorer":
                type = BrowserTypes.IE;
                sVersion = navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE') + 5, navigator.appVersion.length);
                version = parseFloat(sVersion.split(";")[0]);
                switch (parseInt(version)) {
                    case 7:
                        type = BrowserTypes.IE7;
                        break;
                    case 8:
                        type = BrowserTypes.IE8;
                        break;
                    case 9:
                        type = BrowserTypes.IE9;
                        break;
                    case 10:
                        type = BrowserTypes.IE10;
                        break;
                    case 11:
                        type = BrowserTypes.IE11;
                        break;
                    case 12:
                        type = BrowserTypes.IE12;
                        break;
                }
                break;
            case "netscape":
                if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) { type = BrowserTypes.Chrome; }
                else { if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { type = BrowserTypes.FireFox } };
                break;
            default:
                type = BrowserTypes.Unknown;
                break;
        }

        //returns
        return type;
    } catch (ex) {
    }
};

Then all you have to do is use any conditional functionality such as...

ie. value = (Browser() >= BrowserTypes.IE) ? node.text : node.textContent;

or WindowWidth = (((Browser() >= BrowserTypes.IE9) || (Browser() < BrowserTypes.IE)) ? window.innerWidth : document.documentElement.clientWidth);

or sJSON = (Browser() >= BrowserTypes.IE) ? xmlElement.text : xmlElement.textContent;

Get the idea? Hope this helps.

Oh, you might want to keep it in mind to QA the Browser() function after IE10 is released, just to verify they didn't change the rules.

Justin Russo
  • 2,214
  • 1
  • 22
  • 26
2

This worked for me in IE 11:

<meta http-equiv="x-ua-compatible" content="IE=edge; charset=UTF-8">
fender
  • 21
  • 1
1

check whether there is a comma at the end.

                            },
                            {
                                name: 'МОФ. Перелив из баков. м3/ч',
                                data: graph_high3,
                                dataGrouping: {
                                    units: groupingUnits,
                                    groupPixelWidth: 40,
                                    approximation: "average",
                                    enabled: true,
                                    units: [[
                                            'minute',
                                            [1]
                                        ]]
                                }
                            }   // if , - SCRIPT5007
des1roer
  • 220
  • 1
  • 14
  • I was inspired by your solution, then I've better checked my JS indentation that was really poor (written by others). So I've right indented JS code and error disappeared. You know I'm forcing X-UA = IE11 – Tassoman Sep 28 '17 at 12:07
0

You could also get this error if you are viewing accessing the page locally (via file:// instead of http://)..

There is some discussion about this here: https://github.com/jeromegn/Backbone.localStorage/issues/55

Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
-1

Well, you should also try adding the Javascript code into a function, then calling the function after document body has loaded..it worked for me :)

Fazi
  • 3,909
  • 4
  • 27
  • 23
-3

I was also facing the same issue.

I was using the code below in .aspx page without writing authentication configuration in web.config file. After writing the settings in Web.config, I am able to run my code.

<% If Request.IsAuthenticated Then%>
     <table></table>
<%end if%> 
Captain Dando
  • 497
  • 2
  • 11
  • 30