SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calling script via "src=xxx" method

    Hey folks,

    In hopes of keeping my code clean, I put all my javascript into separate files are are calling them via the "src=xxx.js" method.
    Code:
    <script language="JavaScript" src="/includes/script.js"></script>
    <script language="JavaScript1.2" src="/includes/fw_menu.js"></script>
    <script language="JavaScript1.2" src="/includes/scroll.js"></script>
    It works fine, but at times I get errors, I think because it takes a while for the js files to load. I can't tell if the server is just slow...or if there's a problem with calling so much javascript this way.

    Any ideas?

  2. #2
    code addict Abstraction's Avatar
    Join Date
    Apr 2001
    Location
    Des Moines, IA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't run into any problems, what sort of errors are you getting?

  3. #3
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, what's happening is that when a page loads and the server happens to be slow at the particluar moment, then all javascript command on the navbar onMouseOver events cause errors, every object becomes undefined, etc.

    check it out:
    www.brainseeker.com/beta

    I'm thinking that the server is just damn slow...

  4. #4
    code addict Abstraction's Avatar
    Join Date
    Apr 2001
    Location
    Des Moines, IA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That server is slow and it looks like that is the problem. It looks like you'll have to either get a new host or include the javascript in each page.

  5. #5
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you know if it'll work if I do an include file, e.g.,
    Code:
    <!--#include file....-->
    If yes, do I put the script tags within the include file or on the page itself?

  6. #6
    code addict Abstraction's Avatar
    Join Date
    Apr 2001
    Location
    Des Moines, IA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure, but I think it will work. If you do try it you'll need to put the script tags in the include file. I think....I've never tried this before.

  7. #7
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    You could try covering up the errors, if that's the problem. THe code wouldn't work till it's loaded, but it would stop any errors from coming up:

    <script>
    window.onerror = new Function("return false");
    </script>

    aDog

  8. #8
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the help.

    I tried putting the js into an include file and it worked!! so that takes care of the problem since includes are always before client-side scripts...

    But i'm coming across a weird problem. I have drop down menus, with a scrollable layer on the homepage. Only on certain computers running a specific resolution, a menu item on two of the menu don't work...

    it's kinda hard to explain...so here's the url www.brainseeker.com/beta

    Mouse over "company" and "career opportunities" and try to click on the first menu item of each...

    It's a lot of javascript to sift thru and I don't expect anyone to do it for me, but if someone has any ideas of what problem it might be symptomatic of, I'd greatly appreciate it!

    thanks again...

  9. #9
    SitePoint Wizard wdmny's Avatar
    Join Date
    Jul 2000
    Location
    Here
    Posts
    1,010
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you could put all the code into 1 single JS file? I don't know if that would help or not.


Bookmarks

Posting Permissions

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