Closed
Bug 331174
Opened 18 years ago
Closed 13 years ago
getElementsByTagName().length can only be used once
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: petermichaux, Unassigned)
Details
(Keywords: testcase)
Attachments
(2 files)
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 In the following code the burp div does not turn green in Firefox 1.5.0.1 for OS X. In Safari the div does turn green. If you remove st.length then Firefox is able to successfully get a match on script tag with id "bbb". <html> <head> <script type="text/javascript"> var st = document.getElementsByTagName("script"); st.length; </script> <script type="text/javascript" id="bbb"> var scriptTags = document.getElementsByTagName("script"); for(var i=0;i<scriptTags.length;i++) { if(scriptTags[i].id && scriptTags[i].id.match(/bbb/)) { window.addEventListener("load", function(){ document.getElementById("burp").style.background="green"; }, false); } } </script> </head> <body> <div id="burp">Burp</div> </body> </html> Reproducible: Always Steps to Reproduce: 1.Load html document in the details section. Look, no green! 2. 3. Actual Results: no green div background Expected Results: green div background
Updated•18 years ago
|
Assignee: nobody → general
Component: General → DOM: Core
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
Comment 1•18 years ago
|
||
behaves as decribed in comment #0 on Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20060320 SeaMonkey/1.5a
Comment 2•18 years ago
|
||
<script type="text/javascript" id="bbb"> var scriptTags = document.getElementsByTagName("script"); for(var i=0;i<scriptTags.length;i++) { if(scriptTags[i].id && scriptTags[i].id.match(/bbb/)) { window.addEventListener("load", function(){ document.getElementById("burp").style.background="green"; }, false); } } </script> <script type="text/javascript"> var st = document.getElementsByTagName("script"); st.length; </script>
Updated•18 years ago
|
OS: MacOS X → All
Hardware: Macintosh → All
Updated•18 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reporter | ||
Comment 3•18 years ago
|
||
(In reply to comment #2) > Created an attachment (id=215771) [edit] > sequence of scripts reversed If you reverse the sequence of scripts then things probably appear to be ok in this example. However they are not. The second time you try to use any variable that holds document.getElementsByTagName("script") you run into problems. At least I found that to be the case. - Peter
Updated•15 years ago
|
Assignee: general → nobody
QA Contact: ian → general
Comment 4•13 years ago
|
||
attachment 215770 [details] works for me.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•