DelphiFAQ Home Search:
General :: Web publishing :: JavaScript :: Document


Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

getElementById() works in Internet Explorer but fails in Firefox - why?

Question:

getElementById() works in IE but fails in Firefox - why?

Answer:

If you have forgotten to add the element's name as an ID, then Internet Explorer will find it, if the name is given.

// Example:
 
 <input type=checkbox name=acl_type>
 
 // the following will work in IE, but not in FireFox
 var ctrl = document.getElementById('acl_type');
 
 
 // define it like this and it will work both in IE and in FireFox
 <input type=checkbox name=acl_type id=acl_type>
 
 
 

Generated 8:02:17 on Feb 20, 2017