R
Robert Oschler
I'm having a very painful time converting some Mozilla dynamic DOM code to
work with Internet Explore. For example, given this code:
--------------
selectBox=document.createElement("SELECT");
selectBox.name="theSelectBox";
optionOne=document.createElement("OPTION");
optionOne.name="option1";
optionOne.value="one";
optionOne.text="one";
selectBox.appendChild(optionOne);
--------------
This code doesn't work because the option element text property becomes
empty after I execute the appendChild() method. HOWEVER, if I put the
appendChild() call BEFORE I set the "text" property all is well.
This also seems to be the case for several other properties too.
The problem is, a lot of my code was structured around having several child
nodes pre-created, and THEN adding them to the container/parent node. This
worked fine in Mozilla, but because of the above mentioned "quirk", fails
miserably with IE. Annoyingly enough, with IE you HAVE to set the type
before calling appendChild() or IE will throw an error when you try to set
it after the appendChild() call (the type property is write-once only and
apparently calling appendChild() affects the "type" property in some way).
Before I rewrite a whole bunch of code, is there a workaround or a known
technique for dealing with this?
If I am wrong about this, then tell me why I lose the values of certain
properties after I call appendChild()?
Thanks
work with Internet Explore. For example, given this code:
--------------
selectBox=document.createElement("SELECT");
selectBox.name="theSelectBox";
optionOne=document.createElement("OPTION");
optionOne.name="option1";
optionOne.value="one";
optionOne.text="one";
selectBox.appendChild(optionOne);
--------------
This code doesn't work because the option element text property becomes
empty after I execute the appendChild() method. HOWEVER, if I put the
appendChild() call BEFORE I set the "text" property all is well.
This also seems to be the case for several other properties too.
The problem is, a lot of my code was structured around having several child
nodes pre-created, and THEN adding them to the container/parent node. This
worked fine in Mozilla, but because of the above mentioned "quirk", fails
miserably with IE. Annoyingly enough, with IE you HAVE to set the type
before calling appendChild() or IE will throw an error when you try to set
it after the appendChild() call (the type property is write-once only and
apparently calling appendChild() affects the "type" property in some way).
Before I rewrite a whole bunch of code, is there a workaround or a known
technique for dealing with this?
If I am wrong about this, then tell me why I lose the values of certain
properties after I call appendChild()?
Thanks