Subtle Javascript Problem In Firefox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Googler

    Subtle Javascript Problem In Firefox

    Here is the site in question:



    Open it in Firefox (this problem does not occur in IE).

    Click on one of the image thumbnails to see the larger image appear
    (works by changing "display" property). Note how you can arrow up and
    down the page or (if you have it) use your mouse scroll button to move
    up and down the page.

    Click the CLOSE button next to the larger image that appeared.

    Once it disappears, see how you can't scroll anymore? If you click
    again inside the browser window, you can scroll just fine.

    Somewhat annoying.

    I think what's happening is when you click the close button (you can
    also click the larger image to close it as well), it's "display"
    property is set to "none" and then because the last object with focus
    is now no longer displayed, Firefox gets confused about its
    context/position on the page and doesn't allow you to scroll up and
    down until you click inside the window and reset the focus on a visible
    part of the page.

    Do you guys agree? Anyone have any thoughts on how I can fix this?

    I've tried adding an additional last line in the function that toggles
    the display value. That extra line sets the focus to just the window,
    but it doesn't seem to fix the bug.

    Thanks for any ideas you have that might allow me to fix this
    admittedly minor but annoying bug.

    -peter

  • Stephen Chalmers

    #2
    Re: Subtle Javascript Problem In Firefox

    The Googler <google@warcode .com> wrote in message
    news:1106838673 .267069.157020@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > Here is the site in question:
    >
    > http://dev.unmeaningflattery.com/
    >
    > Open it in Firefox (this problem does not occur in IE).
    >
    > Click on one of the image thumbnails to see the larger image appear
    > (works by changing "display" property). Note how you can arrow up and
    > down the page or (if you have it) use your mouse scroll button to move
    > up and down the page.
    >
    > Click the CLOSE button next to the larger image that appeared.
    >
    > Once it disappears, see how you can't scroll anymore? If you click
    > again inside the browser window, you can scroll just fine.
    >
    > Somewhat annoying.
    >
    > I think what's happening is when you click the close button (you can
    > also click the larger image to close it as well), it's "display"
    > property is set to "none" and then because the last object with focus
    > is now no longer displayed, Firefox gets confused about its
    > context/position on the page and doesn't allow you to scroll up and
    > down until you click inside the window and reset the focus on a visible
    > part of the page.
    >
    > Do you guys agree? Anyone have any thoughts on how I can fix this?
    >
    > I've tried adding an additional last line in the function that toggles
    > the display value. That extra line sets the focus to just the window,
    > but it doesn't seem to fix the bug.
    >
    > Thanks for any ideas you have that might allow me to fix this
    > admittedly minor but annoying bug.
    >
    > -peter
    >[/color]

    Check the JS console. Using Mozilla, I get this :
    Error: document.elemen ts has no properties
    Source File: http://dev.unmeaningflattery.com/
    Line: 274

    --
    S.C.



    Comment

    • The Googler

      #3
      Re: Subtle Javascript Problem In Firefox

      That error is left over from me trying to fix this problem. I've now
      removed the error-producing code but the bug is still there.
      Sorry for the confusion.

      Comment

      • Grant Wagner

        #4
        Re: Subtle Javascript Problem In Firefox

        "The Googler" <google@warcode .com> wrote in message
        news:1106840375 .789724.281120@ z14g2000cwz.goo glegroups.com.. .[color=blue]
        > That error is left over from me trying to fix this problem. I've now
        > removed the error-producing code but the bug is still there.
        > Sorry for the confusion.[/color]

        It might just be the way the browsers work. However, this _might_ have
        something to do with it (and you should change it regardless, since the
        use of the javascript: psuedo-protocol is not recommended <url:
        http://jibbering.com/faq/#FAQ4_24 />):

        <A HREF="Javascrip t:changeImages( 'CLOSE18',
        'images_ssi/close_off.gif') ;showhide2('IMG 5FULL');" ...>

        Change that to:

        <a href="#" onclick="
        changeImages('C LOSE18', 'images_ssi/close_off.gif') ;
        showhide2('IMG5 FULL');
        return false;
        " ...>

        (split across lines to make it readable)

        -
        Grant Wagner <gwagner@agrico reunited.com>
        comp.lang.javas cript FAQ - http://jibbering.com/faq


        Comment

        • The Googler

          #5
          Re: Subtle Javascript Problem In Firefox

          Thanks for the tip, Grant!
          I fixed the HREF formatting but the problem still remains.

          -peter

          Comment

          • sunami

            #6
            Re: Subtle Javascript Problem In Firefox

            it seems like it's a browser thing ... but may be this trick will help
            (only tested it against Firefox 1.0)

            here's a modifiied version of your showhide2 function:

            function showhide2(objSh owHide){
            d=document;laye r="";
            if(d.getElement ById)layer1=d.g etElementById(o bjShowHide).sty le;
            else if(d.layers)lay er1=document.la yers[objShowHide];
            //else return 1;

            //alert(layer1.st yle);
            if(layer1.displ ay=="")layer1.d isplay="none";
            //if(layer1.displ ay!="none")laye r1.display="non e";
            //else layer1.display= "block";
            else layer1.display = "";

            d.forms[0].xxx.focus();
            }

            I cleaned it up a bit for clarity. Also, the last line gives the focus
            to a hidden input field. That means, you should put all your page
            content inside a <form> tag and create an <input type="hidden"
            name="xxx"> field (name it whatever). The idea is to give the focus
            back to an element in the page (has to be a form control).
            hope that helps.

            Comment

            Working...