IE8 problem with call through namespace function

I have two js files. I use namespaces in my js files. Here's what the first JS files look like:

(function(common, undefined) {
    "use strict";

    common.FunctionOne = function(){
        //do something
    };

}(window.common = window.common || {}));

The second js file is as follows:

(function(processing, undefined) {
    "use strict";

    processing.FunctionTwo = function(){
         common.FunctionOne()
    };

}(window.processing = window.processing || {}));

On my HTML page, I included the first js first and second later (via tags). I get the error "Unable to get property" FunctionOne "from undefined or null reference" only in IE8. It works great for other browsers.

I'm not sure, but this seems like a namespace problem. It seems that IE8 does not recognize the function defined in the first js file.

Any thoughts?

Thank.

+4
source share
1 answer

jsfiddle

(function(common, undefined) {
    "use strict";

    common.FunctionOne = function(){
        //do something
      $("#one").html("Hi you");
    };

}(window.common = window.common || {}));

(function(processing, undefined) {
    "use strict";

    processing.FunctionTwo = function(){
         common.FunctionOne();
    };

}(window.processing = window.processing || {}));
window.processing.FunctionTwo();

js , , , , , , , - , ?

, , ¿- ? iframe,

; line ,

-1

Source: https://habr.com/ru/post/1532863/


All Articles