By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

BODY is undefined in IE7?!

P: 2
Hi,

I've got a very intermittent problem with IE 7 and could use some suggestions. I have code, that's been working for years, that gets the BODY element that is now not working 100% of the time . So far I've only seen the problem with IE 7. Simply, in a callback of setInterval I have

Expand|Select|Wrap|Line Numbers
  1. var body = document.getElementsByTagName("body")[0];
and at times, body is set to undefined! No sample web page to show you, this is an internal app but that's the only line that's failing. I just can't think of a reason why it would ever be undefined.

thanks,
Jab
Oct 25 '07 #1
Share this Question
Share on Google+
2 Replies


gits
Expert Mod 5K+
P: 5,390
hi ...

welcome to TSDN ...

when ist the problematic line called? is it sure, that the dom of the page is always loaded already?

kind regards
Oct 25 '07 #2

P: 2
Hi glad to be aboard,

This line is in the callback of setInterval -- which is started in the onLoad callback of the body. So the page is loaded and ready. The problem has never been seen when the app is first launched. Folks here leave it up for days at a time. I had it up all day yesterday and left it open last night -- when I came in it had happened to me for the first time and was able to debug it in VisualStudio. Of course, now document.getElementsByTagName("body")[0] is perfectly fine, but at some point last night while it was sitting open on my desktop, it wasn't. That's the confounding part!

thanks,
Jab
Oct 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.