IE work. Firefox Does not...help

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

    IE work. Firefox Does not...help

    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.getEle mentById() 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.getEleme ntById("disp"); ?

    Why does it work with IE and not FF?

    Thanks,

    Tmuld
  • Holger Jeromin

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

    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.getEle mentById() 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.getEleme ntById("disp"); ?
    Try this:
    var e=document.getE lementById("dis p");
    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

    Comment

    • Thomas 'PointedEars' Lahn

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

      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.getEle mentById() 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.getEleme ntById("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.getEle mentById("disp" );
      if (e)
      {
      // ...
      }

      or

      var e = oNug.getElement sByName("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[zeroBasedNumber OrName].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 bugRiddenCrashP ronePieceOfJunk = (
      navigator.userA gent.indexOf('M SIE 5') != -1
      && navigator.userA gent.indexOf('M ac') != -1
      ) // Plone, register_functi on.js:16

      Comment

      • VK

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

        On Apr 24, 7:08 pm, Tmuldoon <tmuld...@splic ed.comwrote:
        FF returns this error:
        >
        Element referenced by ID/NAME in the global scope. Use W3C standard
        document.getEle mentById() instead.
        Well, the error description seems very clear. Don't use
        document.all("d isp") and use document.getEle mentById("disp" ) instead.
        What is exactly not clear here?



        Comment

        • Thomas 'PointedEars' Lahn

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

          VK wrote:
          On Apr 24, 7:08 pm, Tmuldoon <tmuld...@splic ed.comwrote:
          >FF returns this error:
          >>
          >Element referenced by ID/NAME in the global scope. Use W3C standard
          >document.getEl ementById() instead.
          >
          Well, the error description seems very clear. Don't use
          document.all("d isp") and use document.getEle mentById("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>

          Comment

          • GTalbot

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

            On 28 avr, 10:20, VK <schools_r...@y ahoo.comwrote:
            Element referenced by ID/NAME in the global scope. Use W3C standard
            document.getEle mentById() instead.
            >
            Well, the error description seems very clear. Don't use
            document.all("d isp") and use document.getEle mentById("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.getEle mentById("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
            The MDN Web Docs site provides information about Open Web technologies including HTML, CSS, and APIs for both Web sites and progressive web apps.


            Regards, Gérard

            Comment

            • Thomas 'PointedEars' Lahn

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

              GTalbot wrote:
              On 28 avr, 10:20, VK <schools_r...@y ahoo.comwrote:
              >>Element referenced by ID/NAME in the global scope. Use W3C standard
              >>document.getE lementById() instead.
              >Well, the error description seems very clear. Don't use
              >document.all(" disp") and use document.getEle mentById("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.getEle mentById("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:4815E3B4. 4010804@Pointed Ears.de>.


              PointedEars
              --
              var bugRiddenCrashP ronePieceOfJunk = (
              navigator.userA gent.indexOf('M SIE 5') != -1
              && navigator.userA gent.indexOf('M ac') != -1
              ) // Plone, register_functi on.js:16

              Comment

              Working...