/    Sign up×
Community /Pin to ProfileBookmark

appendChild doesn’t work properly on IE

Hello guys. I have following problem: my dynamicaly generated document nodes don’t appear. Here are the parts of source code…

[b]index.html[/b]

[code=php]
<html>
<head>
<script src=”scripts/customGrid.js” type=”text/javascript” language=”javascript”></script>
</head>
<body>
<script language=”javascript” type=”text/javascript”>
<!–
// Grid data
var Data = new Array();
/* here goes aray elements definitions, no problems with them *
–>
</script>
<div id=”divGridContainer”></div>
<script language=”javascript” type=”text/javascript”>
<!–
var oGrid = new clsCustomGrid (“divGridContainer”);
// Configuring grid
oGrid.CellAlign = new Array (“center”, “center”, “left”);
oGrid.Columns = new Array(“id”, “username”, “role”);
oGrid.ColumnHeaders = new Array(“Selection”, “User Name”, “Role”);
oGrid.ColumnTypes = new Array (3, 1, 2);
oGrid.iCurrentPage = 1;
oGrid.iPageCount = 3;
oGrid.bDrawHeader = true;
oGrid.iTableBorder = 1;
// data setup
oGrid.Data = Data;
// Initializing
oGrid.Init();
// Drawing
oGrid.Draw();
–>
</script>
</body>
</html>[/code]

[b]customGrid.js[/b]

[code=php]
// JavaScript Document
function clsCustomGrid (container) {
this.sContainer = container;
this.sGridName = “DATA”;
/* other properties are defined here */
/* ….. */

}
clsCustomGrid.prototype.Draw = function () {
var i, j, k, l;
var iPage;
this.clean ();
// this.DrawFrame ();
var wContainer = document.getElementById (this.sContainer);

// creating top table
var tblTopTable = document.createElement(‘table’);
tblTopTable.style.backgroundColor = “#f0f0f0”;
tblTopTable.setAttribute(‘id’, this.sGridName+’_TopTable’);
tblTopTable.setAttribute(‘border’, this.iTableBorder);
var trHeadTable = document.createElement(‘tr’);
var tdHeadTable = document.createElement(‘td’);
trHeadTable.appendChild (tdHeadTable);
tblTopTable.appendChild (trHeadTable);
// creating form
var frmForm = document.createElement(‘form’);
frmForm.setAttribute(‘action’, ‘index.cfm’);
frmForm.setAttribute(‘method’, ‘POST’);
frmForm.setAttribute(‘target’, ‘_self’);
frmForm.setAttribute(‘id’, this.sFormID);
// creating grid table
var tblGridTable = document.createElement(‘table’);
tblGridTable.setAttribute(‘id’, this.sGridTableID);
tblGridTable.setAttribute(‘border’, this.iTableBorder);
// drawing header
if (this.bDrawHeader) {
var rwGridHeader = document.createElement(‘tr’);
var textNode;
var th;
for (k=0;k<this.ColumnCount;k++) {
if (this.ColumnTypes[k] != 4) {
textNode = document.createTextNode(this.ColumnHeaders[k]);
th = document.createElement (‘th’);
th.appendChild (textNode);
rwGridHeader.appendChild (th);
}
}
tblGridTable.appendChild (rwGridHeader);
}

frmForm.appendChild (tblGridTable);
tdHeadTable.appendChild (frmForm);
wContainer.appendChild(tblTopTable);
}
[/code]

If I’m getting [i]innerHTML[/i] of DIV container I have following:

[code=php]
<TABLE id=DATA_TopTable border=1>
<TR>
<TD>
<FORM id=frmDATA_Grid action=index.cfm method=post target=_self>
<TABLE id=DATA_GridTable border=1>
<TR>
<TH>Selection</TH>
<TH>User Name</TH>
<TH>Role</TH></TR>
</TABLE>
</FORM>
</TD></TR>
</TABLE>
[/code]

… which means that everything is correct but… IE doesn’t draw it!!!
It works fine under O7, NS6 and those browsers draw table well, except of IE.
What am I doing wrong???
Does IE have any specific things?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@djpavlikauthorNov 08.2004 — It seems I found the solution of the problem: IE doesn't want to draw appended nodes of there is no other content drawn into the same nodes' container.

So I've added following line into [b]customGrid.js[/b]:
[code=php]
frmForm.appendChild (tblGridTable);
tdHeadTable.appendChild (frmForm);
wContainer.appendChild(tblTopTable);
// here additional line
wContainer.innerHTML+="";
}
[/code]


... and now everything goes fine!
Copy linkTweet thisAlerts:
@7studNov 08.2004 — Instead of resorting to innerHTML, how about trying one of these instead:

&lt;div id="divGridContainer"&gt;&amp;nbs p;&lt;/div&gt;

or

&lt;div id="divGridContainer"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
Copy linkTweet thisAlerts:
@djpavlikauthorNov 08.2004 — Such thing is also possible.

TNX?
×

Success!

Help @djpavlik spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...