Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Lawrence, Kansas
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Animation to Opening Page: How do I do it?

    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!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    Lawrence, Kansas
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you! This worked really well.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #6
    New Coder
    Join Date
    Oct 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    my dream computer:
    sony viao

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #8
    New Coder
    Join Date
    Oct 2002
    Location
    Lawrence, Kansas
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #9
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #10
    New Coder
    Join Date
    Oct 2002
    Location
    Lawrence, Kansas
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Got it. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •