why does this not work in firefox?

Discussion in 'Javascript' started by darius, Feb 7, 2007.

  1. darius

    darius Guest

    I have popup tooltip aka bubble hint implemented as below (for
    simplicity, I've removed code to position the popup.)

    <script>

    // pop up 'pop' next to object 'obj'
    function popup( obj, pop) {
    pop.style.display="block";
    //
    //
    }

    function unpop( pop ) {
    pop.style.display = "none";
    }

    </script>

    <style>
    ..popupwin {
    display: none;
    }
    </style>


    <DIV name="popupA" ID="popupA" class="popupwin">
    <b>some helpful text</b>
    </DIV>

    <span onmouseover="popup(this,popupA)" onmouseout="unpop(popupA)" > some
    text
    </span>


    Works in IE6 and Opera 9. In FF 1.5, page loads w/o error, but when I
    mouse over, I get "popupA not defined".

    I substituted popupA with document.getElementByID('popupA') in the line
    above and it gave me "document.getElementByID not a function". Huh?

    any idea appreciated
     
    darius, Feb 7, 2007
    #1
    1. Advertising

  2. darius

    RobG Guest

    On Feb 8, 5:51 am, darius <> wrote:
    > I have popup tooltip aka bubble hint implemented as below (for
    > simplicity, I've removed code to position the popup.)
    >

    [...]
    > <DIV name="popupA" ID="popupA" class="popupwin">
    > <b>some helpful text</b>
    > </DIV>
    >
    > <span onmouseover="popup(this,popupA)" onmouseout="unpop(popupA)" > some
    > text
    > </span>
    >
    > Works in IE6 and Opera 9. In FF 1.5, page loads w/o error, but when I
    > mouse over, I get "popupA not defined".


    The FAQ has you answer:

    <URL: http://www.jibbering.com/faq/#FAQ4_41 >


    >
    > I substituted popupA with document.getElementByID('popupA') in the line
    > above and it gave me "document.getElementByID not a function". Huh?


    Because it isn't. :) Use "document.getElementById" with a lower
    case "d".

    --
    Rob
     
    RobG, Feb 7, 2007
    #2
    1. Advertising

  3. darius

    VK Guest

    On Feb 7, 10:51 pm, darius <> wrote:
    > <DIV name="popupA" ID="popupA" class="popupwin">


    DIV doesn't have name attribute - unless you are using your own custom
    DTD with XHTML. Otherwise leave ID only.

    > Works in IE6 and Opera 9. In FF 1.5, page loads w/o error, but when I
    > mouse over, I get "popupA not defined".


    Automatical creation of global var for elements with ID was Microsoft
    "invention". Some other browsers later mimiced it as well in order to
    better survive, but Firefox mimics this behavior only in BackCompat
    (aka Quirk) mode - roughtly when no doctype declaration is presented.
    So "popupA not defined" means that you are using proper DOCTYPE on
    your page in order to put browsers into CSS1Compat mode - good boy you
    are.
    :)

    > I substituted popupA with document.getElementByID('popupA') in the line
    > above and it gave me "document.getElementByID not a function". Huh?


    Try your luck with getElementById ;-)
    JavaScript is case-sensitive, so proper DOM methods spelling is a
    must.
     
    VK, Feb 7, 2007
    #3
  4. darius

    the DtTvB Guest

    Use getElementById()!

    onmouseover="popup(this,document.getElementById('popupA'))"
    onmouseout="unpop(document.getElementById('popupA'))"

    If it looks too long, you can make a variable that is the reference to
    the element.

    var myPopupA = document.getElementById('popupA');

    Then you can call popup(this,myPopupA)
     
    the DtTvB, Feb 8, 2007
    #4
    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. jblazi
    Replies:
    5
    Views:
    459
    jblazi
    Aug 16, 2004
  2. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    504
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    989
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,250
    Smokey Grindel
    Dec 2, 2006
  5. Replies:
    2
    Views:
    88
Loading...

Share This Page