SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot codewrecker's Avatar
    Join Date
    Feb 2002
    Location
    U.S.A.
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript and animated gifs

    I used a javascript function to pass a php variable to a pop up window. The problem is that when the new widow opens the old main page's animated gifs stop cycling. I have to re-load the page to get them working again once the pop up is closed. Does anyone know what the problem might be?

    thanks,
    CodeWrecker

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Long Version
    There is an internal loop within the browser that changes the currently displayed image at each appropriate interval, causing the GIF to "animate." This internal loop should only run for a page while that page is displayed, naturally. So when you click on a link, you are sending a signal that (traditionally) means "we're leaving this page now", and thus, that internal loop is ended. After all, there's no need to continue animating the graphics if we're not going to see them anymore.

    The Short Version
    Your browser thinks you're leaving that page, so it's no longer concerned about displaying that page.

    Possible Workarounds
    I'm not entirely sure, but perhaps having a "return false;" in the onclick event of the link you're clicking may help, but I have not tried this, so I really don't know.

    What has worked for me in the past is to seperate the animated GIF into seperate images, and manage the animation (page flipping) myself by way of javascript's setTimeout() function. This continues to work even while the next page is loading.
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Zealot codewrecker's Avatar
    Join Date
    Feb 2002
    Location
    U.S.A.
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, thanks randem. sound logical for me. I thing I'll just try the method you use.
    CodeWrecker

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using JS to animate animated gifs is a step backward.

    The Browser ( ie at any rate ) will only accept a die link
    as a return case for the clock to stop.

    So instead of using a href="" use span onclick=

    That may do it - though i'm not sure.

    Even once they've stopped - you may find that opener.window.focus() may restart the animation all the same.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    SitePoint Zealot codewrecker's Avatar
    Join Date
    Feb 2002
    Location
    U.S.A.
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code. I'm still very fuzzy on Javascript;


    here's the javascript function;
    Code:
    <script type="text/javascript">
    <!--
    function openWindow(url,winname,w,h)
    {
    
    	popupWin=window.open(url,winname,'scrollbars=yes,menubar=2,resizable=yes,width='+w+',height='+h+',screenX=0,left=0,screenY=0,top=0');
    }
    //-->
    </script>
    here's the relevent php code
    PHP Code:
    echo("<td align=left valign=top><span class='indextext'><b><a href=\"javascript: openWindow('tip_veiw.php?id=$tipid','tipWin','600','550')\">".$tiptitle."</a></b></span></br>"); 
    thanks,
    CodeWrecker


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
  •