/    Sign up×
Community /Pin to ProfileBookmark

[Solved]WTF? Firefox 3.6.8 problem

The following extremely simply JavaScript code:

[code]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<meta http-equiv=”Content-Style-Type” content=”text/css”>
<meta http-equiv=”Content-Script-Type” content=”text/javascript”>
<script type=”text/javascript”>
onload=function(){
var n=document.getElementsByTagName(‘div’)[0];
alert(n.innerHTML);
}
</script>
</head>
<body>
<div>foo</div>
</body>
</html>
[/code]

alerts the innerHTML content. Not in Firefox 3.6.8, which alerts a blank value.

What the f??

I know that innerHTML is not a standard DOM method, but it used to be a crossbrowser one since FF 1.5, right?

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 13.2010 — [font=arial]Hm, that's odd. It should work. I changed it to onclick instead of onload and it worked for me. Does onclick work for you? I haven't tried onload. Maybe it's a bug that has to do with DOM ready on pages that take very little time to load (especially if this is on a local host).[/font]
Copy linkTweet thisAlerts:
@KorauthorSep 13.2010 — It does not work even in case of firstChild.nodeValue or firstChild.data. FF 3.6.8 says that the DIV element has no first child, which is amazing. :eek:
Copy linkTweet thisAlerts:
@KorauthorSep 13.2010 — [font=arial]Hm, that's odd. It should work. I changed it to onclick instead of onload and it worked for me. Does onclick work for you? I haven't tried onload. Maybe it's a bug that has to do with DOM ready on pages that take very little time to load (especially if this is on a local host).[/font][/QUOTE]
It does not work for me, even onclick. Probably there must be something wrong with my FF. I'll reinstall it. To be frank, I did not expect something like that from FireFox... It used to be a trusty browser...
Copy linkTweet thisAlerts:
@KorauthorSep 13.2010 — The same when I upgraded to FF 3.6.9. I am absolutely confused ? If I give the DIV an [B]id[/B], it works. But if I use [B]getElementsByTagName[/B] it does not. The DOM element is present, but FF says it has neither innerHTML, nor childNodes.
Copy linkTweet thisAlerts:
@JonaSep 13.2010 — [font=arial]I copy/pasted your code into a document, saved it, put it on my local server, loaded it in Firefox and it worked fine.

Maybe you have some setting/extension that is making things like this happen? Antivirus software? What about a corrupt Firefox profile?[/font]
Copy linkTweet thisAlerts:
@KorauthorSep 13.2010 — Solved. It is the FireBug 1.5.4 addon fault. Inexplicably, this FireBug version ruins the FF JavaScript interpreter, for a reason or another. When the FireBug's console is closed (or the whole addon is disabled or uninstalled) FF works properly. I should probably write to the FireBug's creators to signal them this bug.
Copy linkTweet thisAlerts:
@JonaSep 13.2010 — [font=arial]Ah, interesting. That's useful to be aware of, though. I probably would have ended up in the same boat as you somewhere along the line. So thanks. ;-) [/font]
Copy linkTweet thisAlerts:
@FangSep 13.2010 — With Fx 3.6.9 and FireBug 1.5.4 no problem
Copy linkTweet thisAlerts:
@KorauthorSep 13.2010 — With Fx 3.6.9 and FireBug 1.5.4 no problem[/QUOTE]
I have now 3.6.9 and FireBug 1.5.4 / Win 7 and [I]there is a problem[/I]. When the Firebug Console is on (enabled), the DOM element found by getElementsByTagName() shows no childNode, at least if the child is the first and the node is a text node.
Copy linkTweet thisAlerts:
@FangSep 13.2010 — I'm using Vista, [I]n.childNodes.length[/I] is 1. Perhaps it's a conflict with other add-ons on your system.
×

Success!

Help @Kor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...