• JavaScript1.2 tags, IE VS NS

    Author
    Topic
    #371633

    I have the following two tags

    Note: I have tried revsing the order of the above tags.

    One (menu.js) contains functions downloaded from Netscapes site. The other (mymenus.js) contains a single function, which uses the functions in menu.js. The idea was to put all of my common menus in a single file. I could, if I have to, add them to the netscape file, however this would not be the best method (not modular)

    All works in Netscape, I recieve an error in IE (Line n, syntax error). However, if I put the single function in the header section of the HTML, or in the file menu.js, the code works in both browsers.

    Is there an issue with accessing multiple script files in IE?

    thanks.

    Viewing 0 reply threads
    Author
    Replies
    • #591261

      To effectively determine a solution, you’d also need to know if the script runs OK by itself. I suspect it has something to do with the script not being loaded at the time that the function is called. It stands to reason that the menu.js that is failing is smaller in size and is probably the first to load. Since the function it references isn’t defined when it loads and starts (the other script hasn’t loaded yet) you get an error.

      From a coding standpoint, I think it makes more sense to have all of the common controls in one source file. In this case you have one script dependent upon another and you cannot control the parsing or loading of either, it is handled internally by IE.

      I did some hunting on the order that items are parsed in IE on MSDN.microsoft.com but wound up with nothing specific – although there is a plethora of information there. Might be worth a dig.

      • #591264

        Fast response. Thanks.

        I also checked MSDN, Netscape, WebMonkey and one or two others. I could not find it. I will try the load speed theory, by inflating my small file.

        From a coding perspective, it does not make sense to have everything in one file. The menu.js functions may be called by 10 or 20 different scripts. If I include the code from menu.js in each, i have to hunt down every instance if I make a change.

        However, since I cannot control parsing, as you stated, OOP goes down the drain when script files are used.

        • #593451

          Is there script in your mymenus.js file that runs immediately? If there is, try delaying execution until the window is loaded (window.onload). I’ve gotten around some problems that way. Not always clean, but workable.

          • #594437

            depending on when you want the code executed it might help to have the code executed as last line in the HTML body this sometimes works even better than the onload.

            cu, L

    Viewing 0 reply threads
    Reply To: JavaScript1.2 tags, IE VS NS

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: