IE work. Firefox Does not...help

Discussion in 'Javascript' started by Tmuldoon, Apr 24, 2008.

  1. Tmuldoon

    Tmuldoon Guest

    Hi,

    I have some Javascript that works on IE 6-7 but not Firefox(FF).

    FF throws this error when clicked:

    Hello,

    Using Publisher 6.2 and Firefox 2.0

    We have a customized Publisher template that creates some Javascript
    that work fine in IE 6-7, but not FF.

    FF returns this error:

    Element referenced by ID/NAME in the global scope. Use W3C standard
    document.getElementById() instead.
    [Break on this error] undefined
    (line 1)
    oNug.all is not a function
    [Break on this error] var e = oNug.all("disp");

    How do I make it W3C compliant? Syntax help please!

    Would I say var e=oNug.getElementById("disp"); ?

    Why does it work with IE and not FF?

    Thanks,

    Tmuld
     
    Tmuldoon, Apr 24, 2008
    #1
    1. Advertising

  2. Tmuldoon schrieb am 24.04.2008 17:08:

    > I have some Javascript that works on IE 6-7 but not Firefox(FF).
    >
    > FF throws this error when clicked:
    >
    > Hello,
    >
    > Using Publisher 6.2 and Firefox 2.0
    >
    > We have a customized Publisher template that creates some Javascript
    > that work fine in IE 6-7, but not FF.


    We need your code for detailed analysis.

    > FF returns this error:
    >
    > Element referenced by ID/NAME in the global scope. Use W3C standard
    > document.getElementById() instead.
    > [Break on this error] undefined
    > (line 1)
    > oNug.all is not a function
    > [Break on this error] var e = oNug.all("disp");
    >
    > How do I make it W3C compliant? Syntax help please!
    >
    > Would I say var e=oNug.getElementById("disp"); ?


    Try this:
    var e=document.getElementById("disp");

    > Why does it work with IE and not FF?


    document.all is a MS invention. After that, the W3C has designed the
    proper DOM functions, which were implemented by FF and MS.

    --
    Mit freundlichen Grüßen
    Holger Jeromin
     
    Holger Jeromin, Apr 24, 2008
    #2
    1. Advertising

  3. Tmuldoon wrote:
    > Using Publisher 6.2


    Your apparently unsuitable development environment hardly matters here.

    > and Firefox 2.0
    >
    > We have a customized Publisher template that creates some Javascript
    > that work fine in IE 6-7, but not FF.
    >
    > FF returns this error:
    >
    > Element referenced by ID/NAME in the global scope. Use W3C standard
    > document.getElementById() instead.
    > [Break on this error] undefined
    > (line 1)
    > oNug.all is not a function
    > [Break on this error] var e = oNug.all("disp");
    >
    > How do I make it W3C compliant? Syntax help please!
    >
    > Would I say var e=oNug.getElementById("disp"); ?


    The error message indicates that `oNug' either does not refer to an object
    that implements the HTMLDocument interface[1] or that Fx's Gecko is
    rendering in Standards Compliance Mode. Therefore:

    var e = document.getElementById("disp");
    if (e)
    {
    // ...
    }

    or

    var e = oNug.getElementsByName("disp");
    if (e && (e = e[0]))
    {
    // ...
    }

    or, if "disp" is the name or ID of a form control within a `form' element:

    var e = document.forms[zeroBasedNumberOrName].elements["disp"];

    (You need to use e[zeroBasedNumber] if there is more than one control with
    that name in the specified form.)

    [1] http://www.w3.org/TR/DOM-Level-2-HTML/html.html

    > Why does it work with IE and not FF?


    Because the `all' property/method is an MSHTML-proprietary feature that is
    only sparsely supported by Fx, and then in Quirks Mode only. Avoid this
    feature.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Apr 28, 2008
    #3
  4. Tmuldoon

    VK Guest

    Re: IE work. Firefox Does not...help

    On Apr 24, 7:08 pm, Tmuldoon <> wrote:
    > FF returns this error:
    >
    > Element referenced by ID/NAME in the global scope. Use W3C standard
    > document.getElementById() instead.


    Well, the error description seems very clear. Don't use
    document.all("disp") and use document.getElementById("disp") instead.
    What is exactly not clear here?
     
    VK, Apr 28, 2008
    #4
  5. Re: IE work. Firefox Does not...help

    VK wrote:
    > On Apr 24, 7:08 pm, Tmuldoon <> wrote:
    >> FF returns this error:
    >>
    >> Element referenced by ID/NAME in the global scope. Use W3C standard
    >> document.getElementById() instead.

    >
    > Well, the error description seems very clear. Don't use
    > document.all("disp") and use document.getElementById("disp") instead.
    > What is exactly not clear here?


    Only that the OP is not using `document.all' at the moment which causes a
    standards-compliant solution to depend on the context in which the
    proprietary `all' property was used before.


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm>
     
    Thomas 'PointedEars' Lahn, Apr 28, 2008
    #5
  6. Tmuldoon

    GTalbot Guest

    Re: IE work. Firefox Does not...help

    On 28 avr, 10:20, VK <> wrote:

    > > Element referenced by ID/NAME in the global scope. Use W3C standard
    > > document.getElementById() instead.

    >
    > Well, the error description seems very clear. Don't use
    > document.all("disp") and use document.getElementById("disp") instead.
    > What is exactly not clear here?


    No... not really. The OP was most likely using

    var e = disp;

    when in fact he should have been using

    var e = document.getElementById("disp");

    In IE, one can get script access to an id-ed element by simply using
    its
    id attribute value.
    It's a very frequent error. And there are still many MSDN articles,
    MSDN
    code examples using the ID attribute to access elements.

    Using Web Standards
    Accessing Elements with the W3C DOM
    http://developer.mozilla.org/en/doc...e_W3C_DOM#Accessing_Elements_with_the_W3C_DOM

    Regards, Gérard
     
    GTalbot, Apr 29, 2008
    #6
  7. Re: IE work. Firefox Does not...help

    GTalbot wrote:
    > On 28 avr, 10:20, VK <> wrote:
    >>> Element referenced by ID/NAME in the global scope. Use W3C standard
    >>> document.getElementById() instead.

    >> Well, the error description seems very clear. Don't use
    >> document.all("disp") and use document.getElementById("disp") instead.
    >> What is exactly not clear here?

    >
    > No... not really. The OP was most likely using
    >
    > var e = disp;
    >
    > when in fact he should have been using
    >
    > var e = document.getElementById("disp");


    You are mistaken. First, there is no need to speculate about the OP's code
    as the offending code is already in the error message, and Firefox's
    behavior is very clear here. Second, see
    <news:>.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Apr 29, 2008
    #7
    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. Yousuf Khan
    Replies:
    5
    Views:
    5,518
    Yousuf Khan
    Oct 18, 2004
  2. minnesotti
    Replies:
    13
    Views:
    875
    nice.guy.nige
    Jul 19, 2006
  3. Christophe Sauvage

    BorderWidth of the control asp:ImageButton does not work in firefox

    Christophe Sauvage, Oct 5, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    123
    Christophe Sauvage
    Oct 5, 2007
  4. Phi!
    Replies:
    1
    Views:
    181
  5. Luke Venediger
    Replies:
    3
    Views:
    150
Loading...

Share This Page