What version of IE uses window [objectName] instead of window.document [objectName]?

I am trying to use a Javascript callback for a Flex application embedded in my page. Looking through some examples, I saw this code used to get a link to a Flex application:

// Get the reference:
function thisFlexApp(appName) {
    if(navigator.appName.indexOf ('Microsoft') != -1) {
        return window[appName];
    }
    else {
        return window.document[appName];
    }
}

// Use it:
var someVariable = thisFlexApp('NameOfFlexApp').callbackMethod();

I used this method, but using IE9 I got errors indicating that calling thisFlexApp is not working. It turns out that window.document [appName] worked in IE9, but window [appName] did not. Since I do not expect my government clients to use IE9, I wonder which version of IE will work on this method? Is there any other test that is better to use instead of the one above, which assumes that all versions of IE work in a certain way? Thanks in advance.

+3
1

, . , window[appName], , .

function thisFlexApp(appName) {
    if(window[appName]) {
        return window[appName];
    }
    else {
        return window.document[appName];
    }
}

:

function thisFlexApp(appName) {
    return window[appName] || window.document[appName];
}
+5

All Articles