Results 1 to 10 of 10

Thread: Stop animation with 1 click

  1. #1
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Stop animation with 1 click

    Hi, new here.

    I'm looking for a simply html script, or whatever is recommended, that will stop an animation playing with 1 click.

    I would prefer something that would allow for image transparency.

    For your information, it is to stop the scales you see in the header on this site.

    Thanks in advance

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What you have there is an animated .gif image. The easiest thing to do would be to have another version of the same image that isn't animated. It can have the same image transparency as the animated version. Then all you would need is a simple script to swap the images. Here is the images code in the source file:

    Code:
    <img src="images/Truth_or_justice.gif" width="110" height="90">
    If you were to do something like so:

    Code:
    <img onclick="this.style.display='none';document.images[1].style.display='';" src="images/Truth_or_justice.gif" width="110" height="90"><img src="images/Truth_or_justice_plain.gif" width="110" height="90" style="display:none;">
    Then just clicking on it would stop the animation.

    Even easier and requiring no clicking would be to edit the image you have and make it so that it only loops a few times and then stops on its own. This can be easily done in any animated .gif editing software.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Sorry for bringing this thread back from the graveyard, but how would you stop it using JS?

    I think there's no way you could do this though.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    As I already outlined, by replacing it with a single frame version of itself. This could actually be done the way I mentioned, or by changing the src attribute of the image tag, or by many other ways as well.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    But there's no way to reliably track which frame is currently being used and to replace it with a single image. Unless it's a timed thing where you know exactly where to replace the image, this seems impossible.
    - Mike

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Oddly, in IE (v 6 and less, at least) there is a bug of sorts (not really a bug, but a very literal interpretation of javascript) that allows for that simply with a link like so:

    Code:
    <a href="javascript:void(0);">Stop Animation</a>
    But, it could also create other problems. For that type of precision in general, stopping an animation in its tracks as it were using javascript, an animated slide show would be best. Another way to get that utility without javascript is Flash.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The void(0); may cause other things to crash if it is a bug in IE, and I wouldn't recommend using it. It seems the only way to do this reliably would be to have a Javascript animation and then you'd be able to control how you want to.
    - Mike

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mburt View Post
    The void(0); may cause other things to crash if it is a bug in IE, and I wouldn't recommend using it. It seems the only way to do this reliably would be to have a Javascript animation and then you'd be able to control how you want to.
    Isn't that what I just said? If you've nothing to add, why do you bother? Trying to up your post count?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Thanks guys.

    Isn't that what I just said? If you've nothing to add, why do you bother? Trying to up your post count?
    As far as I know, mburt added info. from your post.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by tech_support View Post
    Thanks guys.


    As far as I know, mburt added info. from your post.
    Well, if it gave you any information mine did not, I'm not sure what that would be. But, if it did, I guess It was a helpful post. I didn't see any new information there though.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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