SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Animated .gif

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Animated .gif

    is there any way to reload a .gif (that is set to run one time) without refreshing the page?

    Hope someone can help, thanks.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    One way is to put the GIF in an HTML page in an iframe and then reload the iframe source.

    You could also put the GIF in a DIV, then clear the DIV and replace the innerHTML back with the same GIF. (Untested - don't know if this will really work).
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no idea if this will work, give it a try:
    Code:
    var image = document.getElementById("myImage");
    var imgsrc = image.src;
    image.src = "";
    image.src = imgsrc;

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like the div idea, what are you saying Jim?

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just try it:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function reanimate() {
    	var image = document.getElementById("myGif");
    	var imgsrc = image.src;
    	image.src = "";
    	image.src = imgsrc;
    }
    </script>
    </head>
    <body>
    <img id="myGif" src="http://members.aol.com/royalef/gifanim2.gif">
    <button onclick="reanimate();">reanimate</button>
    </body>
    </html>

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ohhh, thats pretty sexy too!


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
  •