...

View Full Version : Animation to Opening Page: How do I do it?



Laura
10-17-2002, 07:44 PM
Hi friends,
I created some cool .gif animation. I want to run the animation and then automatically go to the opening page of my website.
How do I do that? It's not really a link because I want it to be automatic (no onclick). I know this must be simple but I'm stumped. Help!

MCookie
10-17-2002, 10:03 PM
Hi,
the problem is that you don't know how long it takes users to download and see the animation. Downloading the same page may take 3 seconds or 45 seconds or up, depending on a lot of factors. And I don't know if there's a way to detect the end of an animation. Don't think so.
But, there's two ways of redirecting, both used in the head of your page.
In the first one, '5' is five seconds, in the second one, '5000' is five seconds, just adjust the time and the URL.

<meta http-equiv="refresh" content="5; URL=http://www.domain.com/page.html">

or JavaScript:

<script language="JavaScript">
<!--
function redirect()
{
window.location = "http://www.domain.com/page.html"
}
setTimeout("redirect();", 5000)
// -->
</script>

Laura
10-17-2002, 10:20 PM
Thank you! This worked really well.

beetle
10-17-2002, 11:43 PM
Or....

<script>
var img1 = new Image();
img1.src = "animated.gif";
img1.onload = go;

function go() {
setTimeout("window.location='http://www.domain.com/page.html';", 5000)
}
</script>

would probably be more consistent from user to user...

joh6nn
10-18-2002, 12:01 AM
if it's a .gif animation, and you know how long the animation lasts, then you can use the onload event of the image, to wait till the image has finished downloading, and then have it fire off a setTimeout, which waits the length of the animation, and then redirects.

brass fish
10-18-2002, 03:45 AM
i dont think window.location="www.location.com" works on NS4
window.location.replace("www.location.com") i think is more universal, i might be wrong tho

beetle
10-18-2002, 03:53 AM
Oops....thanks brassfish...you made me see a mistake I made...

should be

window.location.href='http://www.domain.com/page.htm';

replace does the same thing, but removes the page from the history.

Laura
10-18-2002, 05:47 PM
Thanks, much.

This worked too:
window.location.href='http://www.domain.com/page.htm';

But, what I think everyone is saying is that if someone's connection is really slow the animation won't finish before it redirects to the opening page. Not good.

Joh6nn seems to have a solution but I don't understand where the onload event goes. I tried but no luck.
Thanks.

beetle
10-18-2002, 06:10 PM
Originally posted by Laura
Joh6nn seems to have a solution but I don't understand where the onload event goes. I did that already!
Originally posted by beetle
Or....

<script>
var img1 = new Image();
img1.src = "animated.gif";
img1.onload = go;

function go() {
setTimeout("window.location.href='http://www.domain.com/page.html';", 5000)
}
</script>

would probably be more consistent from user to user... See? Just set the timeout time to be identical to your animation's time (it's in milliseconds, so here 5000 = 5 seconds)

Laura
10-18-2002, 09:46 PM
Got it. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum