Click to See Complete Forum and Search --> : Script Help


Jick
07-12-2003, 02:18 AM
Ok, here we go! I have this page pre-load script working here:

http://kd7pyo.infinitypages.com/

If you look in the source file you will see that it has three parts:

1. The onload="loadImages()" event in the body tag.
2. The id="hidepage" div thats on the line below it.
3. <SCRIPT LANGUAGE="JavaScript" src="preload.js"></script> in the head tag.

Here is what is in the external js file:
<!-- Begin
function loadImages() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hidepage.visibility = 'hidden';
}
else { // IE 4
document.all.hidepage.style.visibility = 'hidden';
}
}
}
// End -->
I want to convert the stuff in the external js file to a javascript that I can put in the head tag of the same page and have the div and onload link to that instead of the js file. I tried it once already but I didn't get it to work. Can someone help me please? Thank you.

gil davis
07-12-2003, 08:18 AM
Whay can't you get it to work? What does it not do?

All you have to do to include it in the HEAD section instead of using an external .js file is to use a text editor on your HTML page and paste it in. You still need the onload in the body tag.

BTW, I am the original author of the script. You can see an example of how to embed the code in a page at http://gil.davis.home.att.net/space_pics.htm . It's slightly different, but it fully covers the browser window and takes care of a few other small cross-browser issues.

damon2003
07-12-2003, 08:50 AM
Hi, this is a good script, but is it possible to have some sort of counting down percentage display.
For example it could display the total size of the page in kb and dynamically show how many kb have been downloaded so far?

gil davis
07-13-2003, 09:59 AM
No, there isn't anything in client-side javascript that can tell how much is left. I don't think you can tell the connection speed, either, so I don't see any way to calculate it based on a known file size. There is probably some server-side methods, but then you'd have to have a ISP that allows it.