Dropdown menu stays open in IE7

Discussion in 'Javascript' started by dorayme, Sep 17, 2008.

  1. dorayme

    dorayme Guest

    After posting similar in another forum a few hours ago, it strikes me I
    should have subscribed to this group and included it here. There may be
    a simple js tweak that someone knows or can think of:

    Under specific conditions, I have noticed a problem in IE7 with a
    popular dropdown method. In IE7, the dropdown fails to spring back up if
    you focus on another app or window and come back to the doc with the
    dropdown. Anyone come across this who can suggest a simple solution or
    find where such is outlined please:

    <http://dorayme.890m.com/alt/IE7DDFocusProblem.html>

    --
    dorayme
    dorayme, Sep 17, 2008
    #1
    1. Advertising

  2. dorayme wrote:
    > Under specific conditions, I have noticed a problem in IE7 with a
    > popular dropdown method. In IE7, the dropdown fails to spring back up if
    > you focus on another app or window and come back to the doc with the
    > dropdown. Anyone come across this who can suggest a simple solution or
    > find where such is outlined please:
    >
    > <http://dorayme.890m.com/alt/IE7DDFocusProblem.html>


    I can confirm the described behavior in Mozilla/4.0 (compatible; MSIE 7.0;
    Windows NT 5.1; {3E1C4754-F096-BBFE-CD76-3B2E8F19E202}; .NET CLR 1.1.4322;
    ..NET CLR 2.0.50727).

    It may be related to the fact that the value of the `class' attribute when
    the `li' element is hovered over, is invalid. The attribute value is
    defined to be a whitespace-separated list of CSS class names, meaning
    whitespace must be between class names, not preceding a single class name.
    However, the too simple

    sfEls.onmouseover=function() {
    this.className+=" sfhover";
    }

    in the error-prone and too complicated

    sfHover = function() {
    // ...
    }

    just does that. The event listener should be declared a function --

    function sfHover()
    {
    // ...
    }

    -- and should test whether it is OK to precede the new class name with
    whitespace:

    sfEls.onmouseover = function() {
    if (this.className)
    {
    this.className += " sfhover";
    }
    else
    {
    this.className = "sfHover";
    }
    }

    That said, IE 7 supports the :hover CSS pseudo-class for `li' elements, so
    unless you want to blend-in the menu or achieve similar effects, you do not
    need scripting for that (STFW). So

    if (window.attachEvent) window.attachEvent("onload", sfHover);

    in there is pointless in several respects (STFW for "attachEvent").

    <body onload="sfHover()">

    suffices and is standards-compliant, whereas sfHover() should be declared
    before as follows:

    <script type="text/javascript">
    function sfHover() {}
    </script>

    <!--[if lt IE 7]>
    <script type="text/javascript">
    function sfHover()
    {
    // ...
    }
    </script>
    <![endif]-->

    There remains the issue of detecting the capabilities of UAs not based on
    MSHTML, though.

    Incidentally, Suckerfish really sucks.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Thomas 'PointedEars' Lahn, Sep 18, 2008
    #2
    1. Advertising

  3. dorayme

    dorayme Guest

    In article <>,
    Thomas 'PointedEars' Lahn <> wrote:

    > dorayme wrote:
    > > Under specific conditions, I have noticed a problem in IE7 with a
    > > popular dropdown method. In IE7, the dropdown fails to spring back up if
    > > you focus on another app or window and come back to the doc with the
    > > dropdown. Anyone come across this who can suggest a simple solution or
    > > find where such is outlined please:
    > >
    > > <http://dorayme.890m.com/alt/IE7DDFocusProblem.html>

    >
    > I can confirm the described behavior in Mozilla/4.0 (compatible; MSIE 7.0;
    > Windows NT 5.1; {3E1C4754-F096-BBFE-CD76-3B2E8F19E202}; .NET CLR 1.1.4322;
    > .NET CLR 2.0.50727).
    >
    > It may be related to the fact that the value of the `class' attribute when
    > the `li' element is hovered over, is invalid. The attribute value is
    > defined to be a whitespace-separated list of CSS class names, meaning
    > whitespace must be between class names, not preceding a single class name.
    > However, the too simple
    >
    >...


    > That said, IE 7 supports the :hover CSS pseudo-class for `li' elements, so
    > unless you want to blend-in the menu or achieve similar effects, you do not
    > need scripting for that (STFW). So
    > ...
    >
    > There remains the issue of detecting the capabilities of UAs not based on
    > MSHTML, though.
    >
    > Incidentally, Suckerfish really sucks.
    >


    Thanks for your information. It seemed a queer bug in IE7.

    I have a "solution" now, it was detected by someone at alt.html. You can
    read the thread there (similar subject name and recent). Basically it
    was reaction by IE7 to a lack of a change in styling between the state
    of a link and its hover, IE7 seems to need various differences. For
    example commenting out

    dropDownNav, .dropDownNav ul {
    padding: 0;
    margin: 0;
    color: #00c;
    background: #ffc;
    /* list-style-type: none; */
    line-height: 1.8;
    }

    stops the queer phenomenon. Odd bug but have we not come to expect such
    from IE?

    Seems to have nothing to do with the script. Reason I posted is I was
    not sure if there was something in the script IE7 was not liking
    (whether it needed it or not. And whether it needed it or not, I kept
    forgetting! I know that IE6 needs it. (I can test for IE6 but not for
    IE7 just at the moment.)

    Well, I am no fan of dropdwns (never used one) but there came a moment
    where a one level one was a temptation considering it was not essential
    but would be useful for most people. Not sure why you say Suckerfish
    sucks. I would be particular interest in hearing why the example I gave
    (not some other example or multilevel or anything else) sucks in plain
    real life consequences (like, it does not work in popular enough browser
    x, or it really mucks things up for blind folk, or whatever.)

    --
    dorayme
    dorayme, Sep 18, 2008
    #3
    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. Leeor Chernov
    Replies:
    4
    Views:
    13,200
    Leeor Chernov
    Dec 15, 2005
  2. Mike
    Replies:
    1
    Views:
    791
  3. Jeff Louella

    IE7 on XP vs IE7 on Vista

    Jeff Louella, Mar 1, 2007, in forum: HTML
    Replies:
    9
    Views:
    498
    Adrienne Boswell
    Mar 2, 2007
  4. Alan
    Replies:
    8
    Views:
    661
    rossum
    Jun 24, 2005
  5. dorayme
    Replies:
    19
    Views:
    1,030
Loading...

Share This Page