innerHTML / IE6 /NN7

Discussion in 'Javascript' started by Phil N, Jul 13, 2003.

  1. Phil N

    Phil N Guest

    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.getElementById('textArea');
    tA.innerHTML = text;
    }

    Microsoft website says getElementById and innerHTML are supported.

    Maybe my function call:

    <a href="javascript:showText(coachText)">coach</a>
    <a href="javascript:showText(mainText)">main</a>

    Thanks

    --
    Phil Newcombe - philn?telus?net
    http://www3.telus.net/bikim

    Netscape/Gecko/Mozilla - standards conformance and cooperation
    Internet Explorer - standards obfuscation and divergence
    Linux += 30,000/Germany + 80,000/Spain + tomorrow
     
    Phil N, Jul 13, 2003
    #1
    1. Advertising

  2. Phil N

    yzzzzz Guest

    Scripsit "Phil N":

    > 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.getElementById('textArea');
    > tA.innerHTML = text;
    > }
    >
    > Microsoft website says getElementById and innerHTML are supported.
    >
    > Maybe my function call:
    >
    > <a href="javascript:showText(coachText)">coach</a>
    > <a href="javascript:showText(mainText)">main</a>
    >
    > Thanks
    >



    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).
     
    yzzzzz, Jul 13, 2003
    #2
    1. Advertising

  3. Phil N

    Phil N Guest

    yzzzzz wrote:

    > 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).
    >


    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
    http://www3.telus.net/bikim

    Netscape/Gecko/Mozilla - standards conformance and cooperation
    Internet Explorer - standards obfuscation and divergence
    Linux += 30,000/Germany + 80,000/Spain + tomorrow
     
    Phil N, Jul 13, 2003
    #3
  4. Phil N

    DU Guest

    Phil N wrote:

    > 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.getElementById('textArea');
    > tA.innerHTML = text;


    tA.childNodes[0].nodeValue = text;
    or
    tA.childNodes[0].data = text;
    or
    tA.firstChild.nodeValue = text;
    or
    tA.firstChild.data = text;
    will all work faster (from 300% to 2000%) than resorting to non W3C web
    standard innerHTML.

    > }
    >



    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/doctorunclear/HTMLJavascriptCSS/innerHTMLvsNodeValue.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/doctorunclear/HTMLJavascriptCSS/DOM1CharacterData.html



    > Microsoft website says getElementById and innerHTML are supported.
    >
    > Maybe my function call:
    >
    > <a href="javascript:showText(coachText)">coach</a>
    > <a href="javascript:showText(mainText)">main</a>
    >
    > Thanks
    >


    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/
     
    DU, Jul 14, 2003
    #4
  5. Phil N

    DU Guest

    DU wrote:

    > Phil N wrote:
    >
    >> 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.getElementById('textArea');
    >> tA.innerHTML = text;

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

    >
    >
    > 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/doctorunclear/HTMLJavascriptCSS/innerHTMLvsNodeValue.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/doctorunclear/HTMLJavascriptCSS/DOM1CharacterData.html
    >
    >
    >
    >
    >> Microsoft website says getElementById and innerHTML are supported.
    >>
    >> Maybe my function call:
    >>
    >> <a href="javascript:showText(coachText)">coach</a>
    >> <a href="javascript:showText(mainText)">main</a>
    >>
    >> Thanks
    >>

    >
    > 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/
    >


    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:
    http://www10.brinkster.com/doctorunclear/
     
    DU, Jul 14, 2003
    #5
  6. Phil N

    Phil N Guest

    DU wrote:

    > DU
    > --
    > Javascript and Browser bugs:
    > http://www10.brinkster.com/doctorunclear/
    >


    -- 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

    > tA.childNodes[0].nodeValue = text;


    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
    http://www3.telus.net/bikim

    Netscape/Gecko/Mozilla - standards conformance and cooperation
    Internet Explorer - standards obfuscation and divergence
    Linux += 30,000/Germany + 80,000/Spain + tomorrow
     
    Phil N, Jul 14, 2003
    #6
    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. Stephen T. Fox

    javascript in IE6 v NN7.1 & Firefox

    Stephen T. Fox, Jun 11, 2004, in forum: HTML
    Replies:
    1
    Views:
    1,028
  2. Alan Whitener

    XML & NN7

    Alan Whitener, Jul 20, 2003, in forum: XML
    Replies:
    6
    Views:
    1,027
    C. M. Sperberg-McQueen
    Jul 29, 2003
  3. that guy over there
    Replies:
    2
    Views:
    92
    that guy over there
    Aug 11, 2003
  4. Andy Fish

    problem with style.display="none" in NN7

    Andy Fish, Aug 11, 2003, in forum: Javascript
    Replies:
    7
    Views:
    108
    gavin long
    Aug 15, 2003
  5. Carl

    problem with window.print (NN7)

    Carl, Sep 12, 2003, in forum: Javascript
    Replies:
    0
    Views:
    87
Loading...

Share This Page