Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cross Browser Compatability Question

Status
Not open for further replies.

alehambre

Programmer
May 7, 2006
15
US
This page works in IE, but not in Mozilla or Netscape. Could anyone help me figure out why? Am I using unsupported javascript?
-If possible, please suggest an alternate solution.

<html>
<head>
<title>Sample Product Gallery</title>
<script language="JavaScript" type="text/JavaScript">
<!--
//Load the XML to buffer
var xmldoc
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async=false;
xmldoc.load("2006_Print_List.xml");
xmldoc.setProperty("SelectionLanguage", "XPath");
}
// code for Mozilla, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmldoc=document.implementation.createDocument("","doc",null);
xmldoc.load("2006_Print_List.xml");

}
else
{
alert('Your browser cannot handle this script');
}
}


function buildXMLTable() {
var PrintNode = xmldoc.getElementsByTagName("Print");
var allImgFilenames=new Array();
for (var i=0;i<PrintNode.length;i++) {
allImgFilenames.push (PrintNode.getElementsByTagName("file")[0].getAttribute("href"));
}
var mybody = document.getElementsByTagName("body")[0];
var mytable = document.createElement("table");
mytable.setAttribute("border", "0");
var mytablebody = document.createElement("tbody");
var mycurrent_row, mycurrent_cell, imgTag;
var x = 0, y, len = allImgFilenames.length;
while(x<len) {
mycurrent_row = document.createElement("tr");
for(y=0; y<5; ++y) {
mycurrent_cell = document.createElement("td");
if(x<len) {
imgTag = document.createElement("img");
imgTag.src = "images/" + allImgFilenames[x++];
mycurrent_cell.appendChild(imgTag);
} else {
mycurrent_cell.appendChild(document.createTextNode("&nbsp;"));
}
mycurrent_row.appendChild(mycurrent_cell);
}
mytablebody.appendChild(mycurrent_row);
}
mytable.appendChild(mytablebody);
mybody.appendChild(mytable);
}
//-->
</script>
</head>
<body onload="loadXML();buildXMLTable()">

</body>
</html>
 
Is it your dynamic table generation that is failing? If so, you might consider reading this article, "How to Build Tables Dynamically":


It shows the use of "insertRow" and "insertCell" methods.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top