简体   繁体   中英

Javascript object erroring in IE8

    stages = {
            "1": {
                id: "1",
                div: "foo"
            },
            "2": {
                id: "2",
                div: "bar"
            },
            "3": {
                id: "3",
                div: "foobar"
            }
        };

When I run this in Firefox, it's fine. But when run in IE8, I get this error:

Message: Object doesn't support this property or method

Is this a known bug / is there a workaround or is it my syntax?

If there is an element with id=stages in your markup, some browsers create global variable stages as a reference to it. However, IE doesn't support overriding it without declaring it. If you want stages variable to be global, put var stages; to global scope or assign the object to window.stages .

I don't get that error at all. I can define that very code in a javascript file or in the console and it works just fine.

I do see that error if I try and run the code from jsfiddle.net. However the error is referring to code in Action.js and the following code

if (e && e.target.getParent().get('id') == 'm') {

It appears to be unhappy with e.target .

How exactly are you causing that error to popup?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM