Closed
Bug 299108
Opened 20 years ago
Closed 20 years ago
Count of inner layers (childNodes) using JavaScript incorrect in well formatted code
Categories
(Firefox :: General, defect)
Tracking
()
People
(Reporter: jblazer, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Please use this code to reproduce error:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
<!--
function countLayers() {
alert("Number of layers = " +
document.getElementById('maindiv').childNodes.length);
}
// -->
</script>
</head>
<body>
<div id="maindiv">
<div id="subdiv1">Some content</div>
<div id="subdiv2">Some content</div>
<div id="subdiv3">Some content</div>
<div id="subdiv4">Some content</div>
<div id="subdiv5">Some content</div>
</div>
<input type="button" name="countlayer" value="Count Layers"
onClick="countLayers();">
</body>
</html>
Reproducible: Always
Steps to Reproduce:
1. Paste code in new .htm page
2. Open code in browser
3. Press button
Actual Results:
Alertbox stating 11 layers are present
Expected Results:
Alertbox stating 5 layers are present (see MS IE)
Bij sticking all the code together, it will work correctly, but becomes unreadable.Please see: http://www.mozilla.org/docs/dom/technote/whitespace/ *** This bug has been marked as a duplicate of 26179 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Updated•20 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•