PDA

View Full Version : redirect timing....


Chris Carlson
03-09-2000, 01:23 PM
I have a question regarding the timing of a page redirecting. Currently I have an intro page w/ image that redirects after set to "5" ( seconds?) Well I have noticed that with faster connections, the image downloads quick and then they have to wait a few till it redirects. Now for slower connections it seems that by the time it redirects, the image has not fully loaded. So what is the best thing to do, have someone wait awhile for faster connections, or have it redirect quicker but image not show up?
Also, I have a photo album on my church's website....its under the photos header...anywayz I set it do redirect each time so the picture automatically change....but somewhere I have seen where the pictures will change but the page will not...basically I do not want people to feel they are stuck in some redirect trap that shows a picture "slide show" that actually loades more than pictures each time...the entire web page loads each time. Im sure it is a JavaScript of some sort....can anyone help me?

Thanks,

Justin
03-09-2000, 02:07 PM
For the first one, try this:

<body onload=&quot;document.location.href='redirectpage.html';&quot;>

The onload event is called after the page is loaded (including all images), so no matter what the speed of the connection, it will finish loading the image first :)

If you want a mandatory delay *after* the image is loaded, then you would need to use a setTimeout(), calling a function x seconds after the onload() event. I don't recall the exact method at the moment but you should be able to find it by searching for settimeout on any good javascript site...

Not sure I fully understand the second question - but the above might help with that too...?

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support

Chris Carlson
03-09-2000, 04:45 PM
Justin -

That seemed to work....although I havent figured out how to delay the timing after the image is loaded, well probably figure it out sometime. I guess fo rthose who have been to the page before it will redirect quickly...anywayz
do you know how to refresh a page automatically so that people do no t have to click refresh for some of the pages that are updated regularly? possibly a JavaScript?
I was able to figure out the photos to mak ethe photos load instead of the whole page each time.

Thanks,

wolfstalks
03-09-2000, 05:36 PM
Actually I have been debating asking Jusin if he could make the forum main page refresh automatically, so we web servents don't have to constantly hit reload (NS).[nbsp][nbsp]I tried the script that Yahoo uses and , what a surprise???, it didn't work for me LOL

Have a Good One
Bob
...still waiting for that spellchecker...:P

John Kennett
03-10-2000, 03:37 AM
Chris

You can also do the redirect using a meta tag in the head of your document like this:

<meta http-equiv=&quot;Refresh&quot; content=&quot;5; URL=newpage.htm&quot;>

This will load the page, wait five seconds then redirect to the new page. Change the 5 to give a different delay. Note the non-intuitive placement of the quote marks in the content section!

John

Chris Carlson
03-10-2000, 01:20 PM
John -

That META tag seems to work great...but only one problem.
If I have it redirect, say after &quot;5&quot;, for some browsers, the image download time takes longer, ie slower connection.
So they do not get to see the full image . If I change the time to say &quot;15&quot; than for faster connections, or for people who already have visited the site and have it in their temp files than they have to wait a (rather long) 15 seconds.
Justin advised above to insert the script for waiting untill the image loads, than redirecting, that way no matter what connection they have, they get to see the image, but I have yet to find a script for a delay after the onload function. I searched some Javascript sites and still cannot find it. Can anyone help?

Thanks,

Justin
03-10-2000, 04:29 PM
Only because I'm a nice guy, I went ahead and figured this one out for you, and of course it's reduced once again to one line:
</font><font face="Courier" size="3">
<body onload=&quot;setTimeout('document.location.href=\'/whatever.html\';', 2000);&quot;>
</font><font face="Verdana, Arial" size="2">
Mind you, the second set of single quotes has to be escaped - this was the only combination of quotes (since it's being tripple quoted) that I could get to work. The 2000 should be changed to the length of delay you want, in milliseconds (the above is for 2 seconds).

;)

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support<!-- NO_AUTO_LINK -->
[This message has been edited by Justin (edited 03-10-00@4:30 pm)]

Charles Capps
03-10-2000, 06:37 PM
&quot;If I have it redirect, say after &quot;5&quot;, for some browsers, the image download time takes longer, ie slower connection.&quot;

The browser shouldn't be forwarding before the page is loaded...[nbsp][nbsp]Lemme guess, IE?

John Kennett
03-11-2000, 02:10 AM
Ding! That is the correct answer! Come back next week for your chance to win a new car . . .

I've just tested this with a few browsers, and your guess is spot on. IE used to work properly (version 3 was OK, can't find 4 at the moment) and it's fine in Netscape.

IE5, however, just has to do things its own way :(

John