In some cases appendChild() changes the reference to the parent object to
reference the object returned by appendChild().
Example:
var form = document.forms['form1'];
var input = document.createElement('<INPUT name="input1">');
input.type = 'HIDDEN';
input.id = 'id1';
form.appendChild(input);
Sometimes the form variable at this point references the appended INPUT
object. I havn't figured out when this happens, the same code works as
expected in most cases.
I have observed this in IE7.0.5730.11, not in IE6 or FireFox.
HoffLa - 30 Jun 2007 12:06 GMT
Update:
I jumped to conclusions! The problem I had was when I did the following:
var form = document.forms['form1'];
var input = document.createElement('<INPUT name="submit">');
input.type = 'HIDDEN';
input.id = 'id1';
form.appendChild(input);
form.submit(); // IE7 tries to call the INPUT object named submit, which of
course gives an error message.
It is NOT a bug in appendChild(), although the behaviour is new in IE7.
BR
- L