Preloading Images

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Preloading Images

Post by kevin3442 »

Hi All,

I've seen the file, preloadmenuimages.js, mentioned in a few threads recently, where the virtues of preloading your menu images have been discussed. But there really aren't any clear-cut instructions for how to use this file. So, I thought I'd provide some, for those who come looking...

(1) Download preloadmenuimages.js from Milonic, then put it on your web server. It probably makes most sense to put the file in the same location as your menu_data.js file (or whatever you call yours).

(2) Load preloadmenuimages.js into your page at some location after your menus have been defined (i.e., after all the aI() stuff), so that the preload function knows what images it needs to get. For most, that means load preloadmenuimages.js after you load menu_data.js, like this:

Code: Select all

<script language=Javascript src="menu_data.js" type=text/javascript></script>
<script language=Javascript src="preloadmenuimages.js" type=text/javascript></script>
For those who do variations with tables, etc, and move some of the code around, as long as the menus have been defined first, the preload will work, even if the menus have not yet been displayed with drawMenus()

Hope that helps,

Kevin


Keywords:
preload preloading precache images
markbinau
Beginner
Beginner
Posts: 5
Joined: Wed Jun 09, 2004 7:48 pm

Post by markbinau »

Thanks for the info about preloading the images it is very helpful. I noticed in your suggested lines of code that you said
<script language=Javascript src="preloadmenuimages.js" type=text/javascript></script>
In the preloadmenuimages.js file it suggests
<script language="JavaScript1.2" type="text/javascript" src="preloadmenuimages.js"></script>
I am new to JavaScript as will be obvious from this question. What is the difference between language=JavaScript and language=JavaScript1.2?

Is there code in the preloadmenuimages.js that requires 1.2?

What happens if a user's browser does not have 1.2?

Is there a way to determine what version a browser supports?

Is there someplace that lists the version supported by common browsers?

Thanks
Post Reply