N
Nathan Sokalski
I have a rollover script that I plan to use for many of my pages. When I
preload the images, the directories must be relevant to the location of the
HTML file that uses the script, which will not always be the same. Because
of this, I figured the only way to place the script in an external file and
still have it work was to use full path names including everything after the
domain. For example, if my image was located in
http://www.mydomain.com/images/image1.gif, I would like to store the
directory as something like /images/image1.gif so that I have the entire
path entered but do not have to modify it when my domain changes. However,
Javascript does not seem to like the format I showed above. What can I do to
achieve this? The lines of code where this will be used currently look like
the following:
navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_white.gif";
As you can see, the second line will not work for HTML files in directories
other than the root. What should the code look like? Thanks.
preload the images, the directories must be relevant to the location of the
HTML file that uses the script, which will not always be the same. Because
of this, I figured the only way to place the script in an external file and
still have it work was to use full path names including everything after the
domain. For example, if my image was located in
http://www.mydomain.com/images/image1.gif, I would like to store the
directory as something like /images/image1.gif so that I have the entire
path entered but do not have to modify it when my domain changes. However,
Javascript does not seem to like the format I showed above. What can I do to
achieve this? The lines of code where this will be used currently look like
the following:
navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_white.gif";
As you can see, the second line will not work for HTML files in directories
other than the root. What should the code look like? Thanks.