Loading ...
Sorry, an error occurred while loading the content.
 

Baffling Javascript problem

Expand Messages
  • Richard Pearman
    I m trying to make the latest SVG file of my web comic Google Chrome and Safari friendly but I came across a bizare bug. It happens in the version with most
    Message 1 of 2 , May 25, 2009
      I'm trying to make the latest SVG file of my web comic Google Chrome and Safari friendly but I came across a bizare bug. It happens in the version with most the unessecery whitespace removed but not the version with the whitespace. It occures with IE and ASV3, Google Chrome, Renesis (standalone), Opera, Firefox and Safari. When you click on frame 58 it advances to frame 60 instead of frame 59. Both these frames (59 and 60) are very similar and share a great deal of code. To make it more baffling, clicking on the number 59 in the navigation bar (irispective of what frame you're on) will give you frame 59 as will clicking on the foward button when on frame 58.

      Clicking on frame 58 or the foward button will activate the nextFrame(evt) function. This will calculate the next frame from a universal variable and call the function gotoFrame(evt,newFrameNumber), that in turn will call the function f[frameNumber](evt). (Of course [frameNumber] is the number of the frame that should be displayed so if nextFrame(evt) is called when on frame58 gotoFrame(evt,num) will call f59(evt).

      Clicking on a number will call gotoFrame(evt,Num) with the coresponding number as its second argument.

      f59(evt) will call f59p(evt), amoung other things. f60(evt) will also call f59p(evt) along with some stuff that's different from f59(evt).

      I've tried inserting alerts in f59(evt), f59p(evt), f60(evt), gotoFrame(evt) and nextFrame(evt).

      In ASV and Renesis this produces the sequence (when frame 58 is clicked on):

      nextFrame
      gotoFrame
      f59
      f59p
      nextFrame
      gotoFrame
      f60
      f59p
      Then the picture changes to frame 60 and the number 58 on the navigation bar turn black and the number 60 turns white.

      In Google Chrome, Firefox, Safari and Opera it's a bit more compicated:

      nextFrame
      gotoFrame
      f59 - frame 58 dissapears and the number 58 turns black.
      f59p
      nextFrame - frame 59 appears and the number 59 turns white.
      gotoFrame
      f60 - frame 59 dissapears and the number 59 turns black.
      f59p
      Frame 60 appears and the number 60 turns white.

      It appears that there's a second (eronious) call to nextFrame(evt) but differet browsers give different impressions as to when this call occurs. Also why does it happen with the whitespace removed file and not the whitespace file? If it was a problem with extra mouse clicks being registered, it seems unlikely that it would happen just on this frame and this version of the file and on the frame but not the navigation bar but with multiple browsers?

      Does anybody have any ideas about how I can fix this?
    • Helder Magalhães
      Hi Richard, ... As usual, providing an URL with a live example will help: it s just to hard to guess from your text... If you don t intent to put a live sample
      Message 2 of 2 , May 26, 2009
        Hi Richard,

        > Does anybody have any ideas about how I can fix this?

        As usual, providing an URL with a live example will help: it's just to hard to guess from your text...

        If you don't intent to put a live sample online, at least consider creating a reduced test case [1]: during that (the reduction) process, one can even usually understand if the weird behavior was self-caused. ;-)

        Regards,
        Helder

        [1] http://webkit.org/quality/reduction.html
      Your message has been successfully submitted and would be delivered to recipients shortly.