Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript1.2 tags, IE VS NS

    I have the following two tags
    <SCRIPT LANGUAGE="JavaScript1.2" SRC="http://www.jep.cummins.com/javascripts/mymenus.js"></SCRIPT>

    <SCRIPT LANGUAGE="JavaScript1.2" SRC="http://www.jep.cummins.com/javascripts/menu.js"></SCRIPT>

    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.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: JavaScript1.2 tags, IE VS NS

    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.
    -Mark

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: JavaScript1.2 tags, IE VS NS

    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.

  4. #4
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Coppell, Texas, USA
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: JavaScript1.2 tags, IE VS NS

    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.

  5. #5
    New Lounger
    Join Date
    Jun 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: JavaScript1.2 tags, IE VS NS

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •