Closed Bug 269420 Opened 20 years ago Closed 20 years ago

JavaScript api document.getElementById() does not work

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 174617

People

(Reporter: Giora.Katz-Lichtenstein, Assigned: bugzilla)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040818 Firefox/0.9.3ms0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040818 Firefox/0.9.3ms0

When Firefox encounters the JavaScript API call: document.getElementById() it
returns a null for valid elements.

Reproducible: Always
Steps to Reproduce:
1. Save the HTML code below to a file on the file system.
2. Click on the menu options File -->Open File and select the above file
3. The reference to the hidden field should be valid yet it returns a null
Please note that the html below works fine under IE.

<html>
<body>
<form action="bla" />
<input type="hidden" name="control" value="false">
<script Language="JavaScript">
var element = document.getElementById('control');
alert('found the element: ' + element);
</script>

</form>
</body>
</html>


Actual Results:  
found the element: null

Expected Results:  
Under Internet Explorer the results are: found the elment: [object]
It doesnt work because the element has no id. That is what
document.getElementById is for. The fact that name is enough for IE shows that
its an IE bug.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
(In reply to comment #1)
> It doesnt work because the element has no id. That is what
> document.getElementById is for. The fact that name is enough for IE shows 
that
> its an IE bug.

Hi.
You are right on the technical side yet wrong from a business perspective.
I ran the same code with id instead of name and it works fine.
Yet there are countless sites using the getElementById() passing in the name 
as a parameter. Furterhmore, jakarta Struts does not generate an id tag for 
html controls. I think the correct approach is allowing the getElementById to 
take name.

Giora
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
This is actually a duplicate, so whatever you do, dont reopen it. Comment in the
other bug, but I doubt this will be considered, since its invalid.



*** This bug has been marked as a duplicate of 174617 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.