View Full Version : DOM script not working in ie
developer
07-13-2007, 09:34 AM
I have write a simple script to test but it is not working in ie. can anybody help in this regard. the script is as follows:
table=document.createElement('TABLE');
table.border='1';
table.width='444';
tr=document.createElement('TR');
table.appendChild(tr);
td=document.createElement('TD');
tr.appendChild(td);
td.appendChild(document.createTextNode('ererre'));
p3.appendChild(table);
In javascript the TBODY element is required to be mentioned, event if it is not physically written (as in HTML TBODY is optional). In your case, you need to create and to append the TBODY element as well, and only later to append the rows to that TBODY.
And use local variables and CSS :
var table=document.createElement('table');
table.style.border='1px';
table.style.width='444px';
var tbody=document.createElement('tbody');
var tr=document.createElement('tr');
tbody.appendChild(tr);
var td=document.createElement('td');
tr.appendChild(td);
td.appendChild(document.createTextNode('ererre'));
table.appendChild(tbody);
...
developer
07-13-2007, 10:02 AM
thanx
need a help a bit more how can i add a href element using DOM. for example
<a href="index.php">home</a>
i am using document.createTextNode() property to add text can i use innerText and innerHTML property.
Arbitrator
07-15-2007, 08:40 AM
need a help a bit more how can i add a href element using DOM. for example
<a href="index.php">home</a>I think that you mean href attribute.
var anchor = document.createElement("a");
anchor.setAttribute("href", "index.php");
anchor.appendChild(document.createTextNode("home"));
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.