SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    External JavaScript Problem

    Hi. I have the simple scripts that preload images for mouseovers and then execute the mouseovers themselves. Now I'm trying to do the same thing but using external script files so I can use them across many pages and only need to change them once. I assume this is do-able, but what I've tried isn't working.

    Between the <head> tags, I simply have something like <script language="JavaScript" src="preload.js"></script>. Then, the external file just right in with something like this:

    function preload() {
    yadda..
    yadda..
    }
    function highlight(img) {
    yadda..
    }
    etc.

    Then in the body tag, I have onLoad="preload();" and then I've got the usual onMouseOver and onMouseOut event handlers in my markup.

    The mouseovers work, but they are slow, leading me to believe that the images (which are small) aren't pre-loading. I'm sure this is simple.

    Thanks.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks ok from your description/simple example. got a link to your code online? Or try sticking

    alert('hello');

    in as the first line for the preload() function to make sure that it is at least being properly executed.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •