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

A

AAaron123

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

I believe the following is what it is complaining about:

var htmlStyle = document.getElementsByTagName('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
 
N

Nathan Sokalski

I've never used document.getElementsByTagName, but something that the W3C
DOM specifies that you can use to reference the <body> tag is document.body.
This may not help in referencing the <html> tag, but it sounds like you can
survive with either one. Something else you could do is add an id attribute
to the <body> or <html> tag and use document.getElementById, which is
usually more reliable. You may also want to try writing some test code to
see exactly what is returned by document.getElementsByTagName('html') to
help you determine where the problem is. Good Luck!
 
J

Joe Fawcett

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

I believe the following is what it is complaining about:

var htmlStyle = document.getElementsByTagName('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.getElementsByTagName('html');
alert(h.length);
alert(h.innerHTML.substr(0, 100));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top