jim-jim-jim / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

Dynamic Linked Scripts and DOMContentLoaded #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I have a JS file that has been written in object notation.

1. linking to the file in the <script> element and calling a method
in the linked file works fine.

   base2.DOM.bind(document);

    document.addEventListener(
        'DOMContentLoaded',
        function() { 
            myObject.myMethod(arg);
        },
        false
    );

2. My intent is to dynamically load the JS file.
   So the link is removed from the <head> section and the code
modified to:

   ...
        function() { 
            // eliminate non-compliant browsers
            if (!compat()) return;

            // load dynamic scripts and CSS
            loadJsOrCss("j/myObject.js", "js");
            loadJsOrCss("c/myObject.css", "css")
            myObject.myMethod(arg);
        },
        false
    );

This works fine in IE but not in Firefox

3. If I move just the one line call to myObject from the code above to
window load:

     window.addEventListener(
        'load',
        function() {
            myObject.myMethod(arg);
      },
        false
    );

This works fine in Firefox but not in IE

Thus, although solution one works, I would like solution two to go forwards
with.

What version of the product are you using? On what operating system?
Latest version on WinXP

Please provide any additional information below.

Can anyone see what needs to be done to make solution two work?.

Original issue reported on code.google.com by bill.bra...@gmail.com on 19 May 2008 at 4:41

GoogleCodeExporter commented 9 years ago
I'm not sure that this is a problem with base2. Rather, there is a difference 
between
IE and FF in how they load and parse external files. I'm not sure what I am 
supposed
to "fix" exactly.

Original comment by dean.edw...@gmail.com on 26 May 2008 at 3:19