innerHTML / IE6 /NN7

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

    innerHTML / IE6 /NN7

    Hello again

    Site I'm working on: http://www3.telus.net/bikim/lightning/test/

    - 'coach' & 'main' links swap innerHTML of div element - id 'textArea'

    works fine in NN7; IE6 reports 'Object doesn't support this property or method'

    code is:

    function showText(text)
    {
    var tA = document.getEle mentById('textA rea');
    tA.innerHTML = text;
    }

    Microsoft website says getElementById and innerHTML are supported.

    Maybe my function call:

    <a href="javascrip t:showText(coac hText)">coach</a>
    <a href="javascrip t:showText(main Text)">main</a>

    Thanks

    --
    Phil Newcombe - philn?telus?net


    Netscape/Gecko/Mozilla - standards conformance and cooperation
    Internet Explorer - standards obfuscation and divergence
    Linux += 30,000/Germany + 80,000/Spain + tomorrow

  • yzzzzz

    #2
    Re: innerHTML / IE6 /NN7

    Scripsit "Phil N":
    [color=blue]
    > Hello again
    >
    > Site I'm working on: http://www3.telus.net/bikim/lightning/test/
    >
    > - 'coach' & 'main' links swap innerHTML of div element - id 'textArea'
    >
    > works fine in NN7; IE6 reports 'Object doesn't support this property or
    > method'
    >
    > code is:
    >
    > function showText(text)
    > {
    > var tA = document.getEle mentById('textA rea');
    > tA.innerHTML = text;
    > }
    >
    > Microsoft website says getElementById and innerHTML are supported.
    >
    > Maybe my function call:
    >
    > <a href="javascrip t:showText(coac hText)">coach</a>
    > <a href="javascrip t:showText(main Text)">main</a>
    >
    > Thanks
    >[/color]


    You should use an IFrame, it'll be much more accessible and easy to
    maintain than Javascript code (and some people disable javascript to
    avoid popups...).

    But the javascript works fine for me, no errors (IE6 and Mozilla 1.4).

    Comment

    • Phil N

      #3
      Re: innerHTML / IE6 /NN7

      yzzzzz wrote:
      [color=blue]
      > You should use an IFrame, it'll be much more accessible and easy to
      > maintain than Javascript code (and some people disable javascript to
      > avoid popups...).
      >
      > But the javascript works fine for me, no errors (IE6 and Mozilla 1.4).
      >[/color]

      Thanks - I'll look at IFrames. Maybe because I don't have the service packs
      installed? My box went berserk last time I tried that and I had to do a
      pcrestore thing from the W98 cd to get it back.

      --
      Phil Newcombe - philn?telus?net


      Netscape/Gecko/Mozilla - standards conformance and cooperation
      Internet Explorer - standards obfuscation and divergence
      Linux += 30,000/Germany + 80,000/Spain + tomorrow

      Comment

      • DU

        #4
        Re: innerHTML / IE6 /NN7

        Phil N wrote:
        [color=blue]
        > Hello again
        >
        > Site I'm working on: http://www3.telus.net/bikim/lightning/test/
        >
        > - 'coach' & 'main' links swap innerHTML of div element - id 'textArea'
        >
        > works fine in NN7; IE6 reports 'Object doesn't support this property or
        > method'
        >
        > code is:
        >
        > function showText(text)
        > {
        > var tA = document.getEle mentById('textA rea');
        > tA.innerHTML = text;[/color]

        tA.childNodes[0].nodeValue = text;
        or
        tA.childNodes[0].data = text;
        or
        tA.firstChild.n odeValue = text;
        or
        tA.firstChild.d ata = text;
        will all work faster (from 300% to 2000%) than resorting to non W3C web
        standard innerHTML.
        [color=blue]
        > }
        >[/color]


        If the text parameter is a string, then there is no need to resort to
        innerHTML. Just use valid W3C DOM 1 characterData data property or
        nodeValue for such text node.

        Performance comparison between innerHTML method and DOM's nodeValue when
        changing, modifying the text data of a node of type TEXT_NODE



        W3C DOM 1 CharacterData methods and properties are perfectly supported
        by recent versions of major browser manufacturers and other W3C DOM 1
        compliant browsers.

        DOM level 1 CharacterData Interface attributes and methods tests



        [color=blue]
        > Microsoft website says getElementById and innerHTML are supported.
        >
        > Maybe my function call:
        >
        > <a href="javascrip t:showText(coac hText)">coach</a>
        > <a href="javascrip t:showText(main Text)">main</a>
        >
        > Thanks
        >[/color]

        It is widely known and almost universally recognized that resorting to
        "javascript :" pseudo-protocol in href attribute is wrong, bad and bound
        to create problems unless you're creating a bookmarklet.



        Top Ten Web-Design Mistakes of 2002
        6. JavaScript in Links
        "A link should be a simple hypertext reference that replaces the current
        page with new content. (...) of course (...) link is not a piece of code
        that interferes with the browser’s standard behavior."
        Every year brings new mistakes. In 2002, several of the worst mistakes in Web design related to poor email integration. The number one mistake, however, was lack of pricing information, followed by overly literal search engines.


        "Don't use javascript: URLs
        Using a straight http: URL will allow any browser to access the link. If
        you want to use JavaScript for browsers that have JavaScript enabled,
        use the onMouseOver and onClick attributes of the <a href> tag."


        DU
        --
        Javascript and Browser bugs:


        Comment

        • DU

          #5
          Re: innerHTML / IE6 /NN7

          DU wrote:
          [color=blue]
          > Phil N wrote:
          >[color=green]
          >> Hello again
          >>
          >> Site I'm working on: http://www3.telus.net/bikim/lightning/test/
          >>
          >> - 'coach' & 'main' links swap innerHTML of div element - id 'textArea'
          >>
          >> works fine in NN7; IE6 reports 'Object doesn't support this property
          >> or method'
          >>
          >> code is:
          >>
          >> function showText(text)
          >> {
          >> var tA = document.getEle mentById('textA rea');
          >> tA.innerHTML = text;[/color]
          >
          >
          > tA.childNodes[0].nodeValue = text;
          > or
          > tA.childNodes[0].data = text;
          > or
          > tA.firstChild.n odeValue = text;
          > or
          > tA.firstChild.d ata = text;
          > will all work faster (from 300% to 2000%) than resorting to non W3C web
          > standard innerHTML.
          >[color=green]
          >> }
          >>[/color]
          >
          >
          > If the text parameter is a string, then there is no need to resort to
          > innerHTML. Just use valid W3C DOM 1 characterData data property or
          > nodeValue for such text node.
          >
          > Performance comparison between innerHTML method and DOM's nodeValue when
          > changing, modifying the text data of a node of type TEXT_NODE
          > http://www10.brinkster.com/doctorunc...NodeValue.html
          >
          >
          >
          > W3C DOM 1 CharacterData methods and properties are perfectly supported
          > by recent versions of major browser manufacturers and other W3C DOM 1
          > compliant browsers.
          >
          > DOM level 1 CharacterData Interface attributes and methods tests
          > http://www10.brinkster.com/doctorunc...acterData.html
          >
          >
          >
          >[color=green]
          >> Microsoft website says getElementById and innerHTML are supported.
          >>
          >> Maybe my function call:
          >>
          >> <a href="javascrip t:showText(coac hText)">coach</a>
          >> <a href="javascrip t:showText(main Text)">main</a>
          >>
          >> Thanks
          >>[/color]
          >
          > It is widely known and almost universally recognized that resorting to
          > "javascript :" pseudo-protocol in href attribute is wrong, bad and bound
          > to create problems unless you're creating a bookmarklet.
          >
          > http://jibbering.com/faq/#FAQ4_24
          >
          > Top Ten Web-Design Mistakes of 2002
          > 6. JavaScript in Links
          > "A link should be a simple hypertext reference that replaces the current
          > page with new content. (...) of course (...) link is not a piece of code
          > that interferes with the browser’s standard behavior."
          > http://www.useit.com/alertbox/20021223.html
          >
          > "Don't use javascript: URLs
          > Using a straight http: URL will allow any browser to access the link. If
          > you want to use JavaScript for browsers that have JavaScript enabled,
          > use the onMouseOver and onClick attributes of the <a href> tag."
          > http://www.rahul.net/aahz/javascript.html#remove
          >
          > DU
          > --
          > Javascript and Browser bugs:
          > http://www10.brinkster.com/doctorunclear/
          >[/color]

          Please ignore the innerHTML vs nodeValue reference here. Your parameter
          identifiers (function names, parameters, id values) are extremely
          confusing. You're not passing a real TEXT_NODE to your displayText and
          showText functions but markup value first converted as string to be
          processed as new html nodes.

          I would do things quite differently if I were you. Just a <div></div>
          with display:none and with the ability to modify its text node only.
          Maybe there would be more faster, efficient way to do all this... if we
          knew your webpage situation, context more.

          DU
          --
          Javascript and Browser bugs:


          Comment

          • Phil N

            #6
            Re: innerHTML / IE6 /NN7

            DU wrote:
            [color=blue]
            > DU
            > --
            > Javascript and Browser bugs:
            > http://www10.brinkster.com/doctorunclear/
            >[/color]

            -- Not sure if this will appear in the right order in the thread as my ISP seems
            to be delaying some of my posts/emails lately. So this should be after my last
            one. --

            Sorry, forgot to mention I'm not using toggleText() _or_ displayText() here.

            I've changed tA.innerHTML = text;

            to
            [color=blue]
            > tA.childNodes[0].nodeValue = text;[/color]

            as you suggested but it doesn't do what I want - it just displays the raw ascii
            text. I'm sure you understand that but I want to display the actual rendered
            page.

            (I wonder if learning JS/DOM/CSS+browser inconsistencies/bugs+xml/xhtml/ad
            nauseum. is more confusing than calculus?)


            --
            Phil Newcombe - philn?telus?net


            Netscape/Gecko/Mozilla - standards conformance and cooperation
            Internet Explorer - standards obfuscation and divergence
            Linux += 30,000/Germany + 80,000/Spain + tomorrow

            Comment

            Working...