Subtle Javascript Problem In Firefox

Discussion in 'Javascript' started by The Googler, Jan 27, 2005.

  1. The Googler

    The Googler Guest

    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
     
    The Googler, Jan 27, 2005
    #1
    1. Advertising

  2. The Googler <> wrote in message
    news:...
    > 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
    >


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

    --
    S.C.
     
    Stephen Chalmers, Jan 27, 2005
    #2
    1. Advertising

  3. The Googler

    The Googler Guest

    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.
     
    The Googler, Jan 27, 2005
    #3
  4. The Googler

    Grant Wagner Guest

    "The Googler" <> wrote in message
    news:...
    > 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.


    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="Javascript:changeImages('CLOSE18',
    'images_ssi/close_off.gif');showhide2('IMG5FULL');" ...>

    Change that to:

    <a href="#" onclick="
    changeImages('CLOSE18', 'images_ssi/close_off.gif');
    showhide2('IMG5FULL');
    return false;
    " ...>

    (split across lines to make it readable)

    -
    Grant Wagner <>
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Grant Wagner, Jan 27, 2005
    #4
  5. The Googler

    The Googler Guest

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

    -peter
     
    The Googler, Jan 28, 2005
    #5
  6. The Googler

    sunami Guest

    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(objShowHide){
    d=document;layer="";
    if(d.getElementById)layer1=d.getElementById(objShowHide).style;
    else if(d.layers)layer1=document.layers[objShowHide];
    //else return 1;

    //alert(layer1.style);
    if(layer1.display=="")layer1.display="none";
    //if(layer1.display!="none")layer1.display="none";
    //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.
     
    sunami, Jan 29, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jo Inferis

    The Subtle Application of Style

    Jo Inferis, Jan 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    344
    Daniel Fisher\(lennybacon\)
    Jan 11, 2005
  2. Replies:
    6
    Views:
    452
    Patricia Shanahan
    Aug 24, 2005
  3. stixwix
    Replies:
    2
    Views:
    1,177
    Thomas Fritsch
    Nov 30, 2005
  4. jimspace

    Subtle Bugs in c++ hunt

    jimspace, May 4, 2005, in forum: C++
    Replies:
    7
    Views:
    435
    John Carson
    May 5, 2005
  5. King Coffee

    A subtle problem with IntelliSense

    King Coffee, Apr 23, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    334
    King Coffee
    Apr 23, 2010
Loading...

Share This Page