Forum Moderators: not2easy
in a file, does this load the image in the browser's cache, thus if that file is used in a second file, it will be preloaded? Or does the above code ONLY load the image for that particular file and it is not in the cache subsequently?
Thanks
As for caching the image - if the same image is used with another call to the image object (ie: the src file name is the same) then the browser will use the cached image file.
images.js - creates Image() object with src="graphics/image.jpg"
images_sub.js - creates Image() object with src="../graphics/image.jpg"
basically I have a navbar that I want to always load but sometimes it is in a subdirectory (i use the second version for the include in a subdirectoyr), so I'm wondering if when just one of the above files is loaded the first time, then for ANY file in any subdirectory including one or the other of the above src files, the file is loaded from the browser cache...
Try a relative path like this: /subdir1/filename.ext. Note the leading '/'. In this case the path would never change regardless of what directory you called the image file from and therefore the image should be cached and re-used.