Forum Moderators: open
Thanks so much.
I was wondering when you were going to get your question posted.
preloading,
there are a lot of different ways to do this I am sure but here is what I use, people will inevitably have better solutions but I have used this for a couple of years now and it has served me well. I just do it straight up in the head, I don't call a function onload or anything like that.
var canUseImageArray = false;
if (document.images){
canUseImageArray = true;
}
if (canUseImageArray) {
menu1_on = new Image();
menu1_on.src = "/images/img1-on.gif";
menu1_off = new Image();
menu1_off.src = "/images/img1-off.gif";
menu2_on = new Image();
menu2_on.src = "/images/img2-on.gif";
menu2_off = new Image();
menu2_off.src = "/images/img2-off.gif";
}
then a function like this for the rolls
function rollmeover(pic,state) {
if (state == "on") {
document.images[pic].src = eval(pic + "_on.src");
} else if (state == "off") {
document.images[pic].src = eval(pic + "_off.src");
}
}
As for including common footers with javascript, I have never done that and I am not totally sure you can. I use php for that purpose.
You create the footer as a stand-alone file, and then insert a line in your page code where you want the footer to appear:
<!--#include file="footer.html" --> (make sure the footer.html file is in the same directory as the pages you want it to appear on)
Most hosts will require pages that use server side includes (SSI) to use the extension ".shtml" but (This won't work on Windows hosting), you can often get around that by creating a file called ".htaccess" (saved as a plain text file with a plain text program like notepad), that has the following line in it:
AddHandler server-parsed .html .htm .shtml If your host's server is configured to allow that trick, you can keep the regular .htm or .html extensions on your pages, and still use SSI calls for your footer file.
(There are a lot of other really cool things you can do with your .htaccess file, but that's all you need to know for SSI in a plain .html file. ;) )
if (document.images){...}