473,412 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

A very DOM question

You guys have been very helpful. Even if the solution was not presented in the reply, then you would at least spark a thought which would lead to the solution and I am very grateful for your assistance and I require your assistance once more.

I have been working with DOM to interact with AJAX/PHP/MySQL/XML and I have it working perfectly within Safari, Firefox (linux/mac/win) and Opera, but not with IE. So, I used a conditional statement to hard code in what I wanted IE to display, but it still doesn't work properly.

I know that it must be something simple that I missing, but IE draws the info being retrieved with a black background and white text, which is the opposite effect that I am seeking. Plus, the two table datas on the sides of the incoming data are not drawing the background images either.

Here's the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.             loadXMLDoc('xml/crew2.xml');
  3.         crews = xml_doc.getElementsByTagName("crew");
  4.         members = xml_doc.getElementsByTagName("member");
  5.  
  6.             if(navigator.appName == 'Microsoft Internet Explorer')
  7.             {    
  8.         theDiv = document.getElementById('contentHoldingDiv');
  9.         theDiv.innerHTML = '';
  10.         theDiv.innerHTML += '<table bgcolor=#000000 cellpadding=0 cellspacing=0>';
  11.         theDiv.innerHTML += '<tr>';
  12.         theDiv.innerHTML += '<td style="padding:0; margin:0;" colspan=3 valign=bottom>';
  13.         theDiv.innerHTML += '<img src=images/crew_description_bg_tp.jpg width=560px height=43px>';
  14.         theDiv.innerHTML += '</td></tr><tr bgcolor=#FFFFFF>';
  15.         theDiv.innerHTML += '<td style="padding: 0; margin: 0; background-color:#FFFFFF;background-image:url(images/crew_description_bg_ls.jpg); background-repeat:repeat-y; width:15px;" valign=top width=15px align=right>&nbsp;</td>';
  16.         theDiv.innerHTML += '<td valign=top style="font-size:10px; width:528px; background-color:#FFFFFF; color:#000000; padding:0; margin:0; white-space:inherit;">';
  17. theDiv.innerHTML += '<p>' + members[someNumberComing].childNodes[0].nodeValue + '</p></td>';
  18.         theDiv.innerHTML += '<td style="padding: 0; margin: 0; background-color:#FFFFFF;background-image:url(images/crew_description_bg_rs.jpg); background-repeat:repeat-y; width:17px;" valign=top width=17px align=left>&nbsp;</td>';
  19.         theDiv.innerHTML += '</tr><tr>';
  20.         theDiv.innerHTML += '<td style="padding:0; margin:0;" colspan=3 valign=top>';
  21.         theDiv.innerHTML += '<img src=images/crew_description_bg_btm.jpg width=560px height=43px>';
  22.         theDiv.innerHTML += '</td></tr></table>';
  23.             }
  24.             else
  25.             {
  26.         theDiv = document.getElementById('contentHoldingDiv');
  27.         myTable = document.createElement('table');
  28.         myTable.setAttribute('bgcolor','#000000');
  29.         myTable.setAttribute('cellpadding','0');
  30.         myTable.setAttribute('cellspacing','0');
  31.         myTd = document.createElement('td');
  32.         myTd.setAttribute('style','font-size: 10px; width:528px; background-color:#FFFFFF; color:#000000; padding: 0; margin: 0; white-space:inherit;');
  33.         myTd.setAttribute('valign','top');
  34.         myTr = document.createElement('tr');
  35.         myTr.setAttribute('bgcolor','#FFFFFF');
  36.  
  37.         myTrTop = document.createElement('tr');
  38.         myTrBottom = document.createElement('tr');
  39.  
  40.         //var tdHeight = document.getElementById('contentHoldingDiv').height;
  41.         //alert(tdHeight);
  42.  
  43.         myTdTop = document.createElement('td');
  44.         myTdTop.setAttribute('colspan','3');
  45.         myTdTop.setAttribute('style','padding: 0; margin: 0;');
  46.         myTdTop.setAttribute('valign','bottom');        
  47.         myTdBottom = document.createElement('td');
  48.         myTdBottom.setAttribute('colspan','3');
  49.         myTdBottom.setAttribute('style','padding: 0; margin: 0;');
  50.         myTdBottom.setAttribute('valign','top');
  51.  
  52.         myTopImage = document.createElement('img');
  53.         myTopImage.setAttribute('src','images/crew_description_bg_tp.jpg');
  54.         myTopImage.setAttribute('width','560px');
  55.         myTopImage.setAttribute('height','43px');
  56.  
  57.         myBottomImage = document.createElement('img');
  58.         myBottomImage.setAttribute('src','images/crew_description_bg_btm.jpg');
  59.         myBottomImage.setAttribute('width','560px');
  60.         myBottomImage.setAttribute('height','43px');
  61.  
  62.         myLeftImageTd = document.createElement('td');
  63. myLeftImageTd.setAttribute('style','padding: 0; margin: 0; background-color:#FFFFFF;background-image:url(images/crew_description_bg_ls.jpg); background-repeat:repeat-y; width:15px;position:relative; left:2px;');
  64.         myLeftImageTd.setAttribute('valign','top');
  65.         myLeftImageTd.setAttribute('width','15px');
  66.         myLeftImageTd.setAttribute('align','right');
  67.  
  68.         /* myLeftImage = document.createElement('img');
  69.         myLeftImage.setAttribute('src','images/crew_description_bg_ls.jpg');
  70.         myLeftImage.setAttribute('width','16px');
  71.         myLeftImage.setAttribute('height','140px'); */
  72.  
  73.         myRightImageTd = document.createElement('td');
  74. myRightImageTd.setAttribute('style','padding: 0; margin: 0; background-color:#000000;background-image:url(images/crew_description_bg_rs.jpg); background-repeat:repeat-y; width:17px;');
  75.         myRightImageTd.setAttribute('valign','top');
  76.         myRightImageTd.setAttribute('width','17px');
  77.         myRightImageTd.setAttribute('align','left');
  78.  
  79.         /* myRightImage = document.createElement('img');
  80.         myRightImage.setAttribute('src','images/crew_description_bg_rs.jpg');
  81.         myRightImage.setAttribute('width','16px');
  82.         myRightImage.setAttribute('height','140px'); */
  83.  
  84.         theDiv.innerHTML = '';
  85.  
  86.         theDiv.appendChild(myTable);
  87.         myTable.appendChild(myTrTop);
  88.         myTrTop.appendChild(myTdTop);
  89.         myTdTop.appendChild(myTopImage);
  90.         myTable.appendChild(myTr);
  91.         myTr.appendChild(myLeftImageTd);
  92.         /* myLeftImageTd.appendChild(myLeftImage); */
  93.         myTr.appendChild(myTd);
  94. myTd.innerHTML += '<p>' + members[someNumberComing].childNodes[0].nodeValue + '</p>';
  95.         myTr.appendChild(myRightImageTd);
  96.         /* myRightImageTd.appendChild(myRightImage); */
  97.         myTable.appendChild(myTrBottom);
  98.         myTrBottom.appendChild(myTdBottom);
  99.         myTdBottom.appendChild(myBottomImage);
  100.             }
  101.  
  102.  
Once more, this works perfectly in Safari, Firefox & Opera and, as usual, I thank you in advance. :-) Any thoughts would be most appreciated.
Jun 26 '07 #1
3 1973
acoder
16,027 Expert Mod 8TB
When appending children, you should work the other way round adding to the body or main containing div at the end. Maybe the fact that you're adding the table (with a black background) and then adding the rows/cells afterwards is causing the problem.
Jun 26 '07 #2
When appending children, you should work the other way round adding to the body or main containing div at the end. Maybe the fact that you're adding the table (with a black background) and then adding the rows/cells afterwards is causing the problem.
That is what is so strange about this situation. I had tried that, but I do not have an issue with the browsers (everything other than IE) using the DOM to create the table, for which the black background is used to make the images on the left and right side of the table to appear seamlessly, but the issue that I'm having is with the hard coded table that is being written for IE.

It actually has a black background with white text in the center td and I can not figure out why. And why is IE not drawing the side tds?

Thanks for your thoughts and please keep them coming. I think I will try something as a result of your comment.
Jun 26 '07 #3
OK, I was able to add a "<div>" tag with a style, rather than the "<p>" tag, followed by making the #contentHoldingDiv within my css file to have a white background, which solved my black background and white text issue.

However, the background-repeat: repeat-y; within the left and right td is still not functioning in IE.

Here's the fix of the original problem:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         theDiv = document.getElementById('contentHoldingDiv');
  3.         theDiv.innerHTML = '';
  4.         theDiv.innerHTML += '<table bgcolor=#000000 cellpadding=0 cellspacing=0>';
  5.         theDiv.innerHTML += '<tr>';
  6.         theDiv.innerHTML += '<td style="padding:0; margin:0;" colspan=3 valign=bottom>';
  7.         theDiv.innerHTML += '<img src=images/crew_description_bg_tp.jpg width=560px height=43px>';
  8.         theDiv.innerHTML += '</td></tr><tr>';
  9.         theDiv.innerHTML += '<td style="padding: 0; margin: 0; background-image:url(images/crew_description_bg_ls.jpg); background-repeat:repeat-y; width:15px;" valign=top width=15px align=right></td>';
  10.         theDiv.innerHTML += '<td valign=top style="font-size:10px; width:528px; background-color:#FFFFFF; color:#000000; padding:0; margin:0;">';
  11. theDiv.innerHTML += '<div style="position:relative; left:15px; top:0px; width:528px; background-color:#FFFFFF; color:#000000; font-family:Arial, Helvetica, sans-serif; font-size: 12px; padding:0; margin:0;">' + members[someNumberComing].childNodes[0].nodeValue;
  12.         theDiv.innerHTML += '</div></td><td style="padding: 0; margin: 0; background-image:url(images/crew_description_bg_rs.jpg); background-repeat:repeat-y; width:17px;" valign=top width=17px align=left></td>';
  13.         theDiv.innerHTML += '</tr><tr>';
  14.         theDiv.innerHTML += '<td style="padding:0; margin:0;" colspan=3 valign=top>';
  15.         theDiv.innerHTML += '<img src=images/crew_description_bg_btm.jpg width=560px height=43px>';
  16.         theDiv.innerHTML += '</td></tr></table>';
  17.  
  18.  
As usual, thank you for your help. As with the last comment, it allowed me to start thinking of the solution above.
Jun 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.