Click to See Complete Forum and Search --> : Some More Simple Stuff


DJRobThaMan
07-24-2003, 10:32 AM
I was just wondering. Do you think you can use javascript to preload a page?

For example, you make the index something like

<html>
<head>
<script language="JavaScript">
<!--

var images = newArray();
var i = 0;
images[i] = document.pic + i + .src;
++i;
// I can't remember how to cache images offhand. I know it's something like this. I have the code on my computer but I'm at work right (yeah I know I'm a slacker but hey... )

function gotorealindex(){
preload = setInterval("a function where I have something moving to show the page is loading",20);
}

function the one being cleared(){
blahblahblah(code for animation);
if(i == 10){
//assuming there are 11 images
clear Interval(preload);
document.location = index location(wherever that is);
}
-->
</script>
</head>
<body>
<img src....>
</body>
</html>



Do you think the images would load with the first page so the real index would just kinda pop up really quickly... or not?

Tell me what you think

DJRobThaMan
07-24-2003, 02:32 PM
...

Exuro
07-24-2003, 02:34 PM
Uhm, yeah sure. That might help... But why don't you just try it and see if you like how it works? That'd be the best way to do it in my opinion...

DJRobThaMan
07-24-2003, 04:04 PM
Well I'm not gonna be able to test it until late August cuz I don't cuz I'm not gonna be able to get to my personal CPU till then. I can use my dad's but he's on a dial up connection and not even a good one at that. I also can't upload to my server to upload with what he has and even if I took the hour to download some program I'm not fully sure it will work while I'm off the lan cuz right now I caqn't connect through telnet.


So I was just wondering along the lines of would that work as a way to preload a page?

Exuro
07-24-2003, 05:16 PM
Okay then, yeah, I think something like that would work. But what I'd do is have a hidden division on the page (maybe moved off the side of the screen with absolute positioning) that contains all the images. Each of these images would have an onLoad="callFunction()". Inside that function there'd be a little increment for the global variable numPics, and then there'd be an "if (numPics==11) {parent.location='home.html'}. Something along those lines... I've never actually done a preload before so I'm not sure how well that would work though...

pyro
07-24-2003, 05:30 PM
Remembering, of course, that if your site relies on javascript, your page won't display at all for 13% of web users. Worth it? No...

DJRobThaMan
07-25-2003, 08:41 AM
Point taken.


So, any suggestions?

CGI maybe?
I'm not sure how to load it up like that tho

hmmm...