document.getElementsByTagName('html')[0].style; produces an error

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

    #1

    document.getElementsByTagName('html')[0].style; produces an error

    Warning 2 Error updating JScript IntelliSense: ..snip.. ColorScrollbar. js:
    'document.getEl ementsByTagName (...).0.style' is null or not an object

    I believe the following is what it is complaining about:

    var htmlStyle = document.getEle mentsByTagName( 'html')[0].style;

    I tried 'body' instead of "html" and got the same error in my error list
    pane.

    Do you understand what is wrong?


    Thanks


  • Nathan Sokalski

    #2
    Re: document.getEle mentsByTagName( 'html')[0].style; produces an error

    I've never used document.getEle mentsByTagName, but something that the W3C
    DOM specifies that you can use to reference the <bodytag is document.body.
    This may not help in referencing the <htmltag, but it sounds like you can
    survive with either one. Something else you could do is add an id attribute
    to the <bodyor <htmltag and use document.getEle mentById, which is
    usually more reliable. You may also want to try writing some test code to
    see exactly what is returned by document.getEle mentsByTagName( 'html') to
    help you determine where the problem is. Good Luck!
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


    "AAaron123" <aaaron123@road runner.comwrote in message
    news:uESu3tVNJH A.4772@TK2MSFTN GP03.phx.gbl...
    Warning 2 Error updating JScript IntelliSense: ..snip.. ColorScrollbar. js:
    'document.getEl ementsByTagName (...).0.style' is null or not an object
    >
    I believe the following is what it is complaining about:
    >
    var htmlStyle = document.getEle mentsByTagName( 'html')[0].style;
    >
    I tried 'body' instead of "html" and got the same error in my error list
    pane.
    >
    Do you understand what is wrong?
    >
    >
    Thanks
    >

    Comment

    • Joe Fawcett

      #3
      Re: document.getEle mentsByTagName( 'html')[0].style; produces an error



      "AAaron123" <aaaron123@road runner.comwrote in message
      news:uESu3tVNJH A.4772@TK2MSFTN GP03.phx.gbl...
      Warning 2 Error updating JScript IntelliSense: ..snip.. ColorScrollbar. js:
      'document.getEl ementsByTagName (...).0.style' is null or not an object
      >
      I believe the following is what it is complaining about:
      >
      var htmlStyle = document.getEle mentsByTagName( 'html')[0].style;
      >
      I tried 'body' instead of "html" and got the same error in my error list
      pane.
      >
      Do you understand what is wrong?
      >
      >
      Thanks
      >
      Try getting the collection and making sure it is one. Some of the IE methods
      incorrectly return single instances rather than collections when there is
      only one.
      var h = document.getEle mentsByTagName( 'html');
      alert(h.length) ;
      alert(h.innerHT ML.substr(0, 100));

      --

      Joe Fawcett (MVP - XML)


      Comment

      Working...