A simple javascript code not working on Firefox

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

    A simple javascript code not working on Firefox

    Hello,

    I have a code that works on both the IE and Opera, but not the
    Firefox, and I cannot figure out the reason. Following is the page:



    And following is the code:

    function chinText()
    {
    document.getEle mentById("moon" ).innerText ="\u6708";

    document.getEle mentById("tree" ).innerText ="\u6728";

    document.getEle mentById("man") .innerText ="\u4eba";

    document.getEle mentById("water ").innerTex t ="\u6c34";
    }

    Thanks for your expertise and help.
    fulio pen
  • Tom Cole

    #2
    Re: A simple javascript code not working on Firefox

    On Sep 9, 7:37 am, fulio pen <fulio...@yahoo .comwrote:
    Hello,
    >
    I have a code that works on both the IE and Opera, but not the
    Firefox, and I cannot figure out the reason.  Following is the page:
    >

    >
    And following is the code:
    >
    function chinText()
    {
      document.getEle mentById("moon" ).innerText ="\u6708";
    >
    document.getEle mentById("tree" ).innerText ="\u6728";
    >
    document.getEle mentById("man") .innerText ="\u4eba";
    >
    document.getEle mentById("water ").innerTex t ="\u6c34";
    >
    }
    >
    Thanks for your expertise and help.
    fulio pen
    Firefox does not support the innerText function. You can use an
    alternative, (like innerHTML) which is also not standard, but
    supported in most browsers.

    Comment

    • fulio pen

      #3
      Re: A simple javascript code not working on Firefox

      On Sep 9, 7:49 am, Tom Cole <tco...@gmail.c omwrote:
      On Sep 9, 7:37 am, fulio pen <fulio...@yahoo .comwrote:
      >
      >
      >
      Hello,
      >
      I have a code that works on both the IE and Opera, but not the
      Firefox, and I cannot figure out the reason.  Following is the page:
      >>
      And following is the code:
      >
      function chinText()
      {
        document.getEle mentById("moon" ).innerText ="\u6708";
      >
      document.getEle mentById("tree" ).innerText ="\u6728";
      >
      document.getEle mentById("man") .innerText ="\u4eba";
      >
      document.getEle mentById("water ").innerTex t ="\u6c34";
      >
      }
      >
      Thanks for your expertise and help.
      fulio pen
      >
      Firefox does not support the innerText function. You can use an
      alternative, (like innerHTML) which is also not standard, but
      supported in most browsers.
      Hi, Tom:

      innerHTML works well. Thanks a million for your help.

      fulio pen

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: A simple javascript code not working on Firefox

        Tom Cole wrote:
        Firefox does not support the innerText function.
        Correct, except that it is a non-function property of element objects.
        You can use an alternative, (like innerHTML) which is also not standard,
        but supported in most browsers.
        `firstChild.nod eValue' (W3C DOM Level 1+) would probably be a viable
        alternative here. `textContent' (W3C DOM Level 3 Core) is AFAIK supported
        since Gecko 1.7.8 (Firefox 1.5), Opera 9.0.8367, and Safari 3.0.4.


        PointedEars
        --
        realism: HTML 4.01 Strict
        evangelism: XHTML 1.0 Strict
        madness: XHTML 1.1 as application/xhtml+xml
        -- Bjoern Hoehrmann

        Comment

        Working...