I am creating a script that I will use to rotate flash banners, and will get the parameters from a XML file. This will eventually be incorporated into a .Net user control. For now I am just writing the client side script to get it working. The problem:
The below script works in IE, but I cannot get it to work in NN, FireFox etc.
Q1) Can anyone tell me why this does not work in NN, FireFox etc?
Q2) Can anyone tell me how to get the total node count from a XML file?
The Script:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = createTable;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {if (xmlDoc.readyState == 4) createTable()};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("../ctrlTemp/xml/intAd/intFlsAdSysblk.xml");
}
function createTable()
{
var x = xmlDoc.getElementsByTagName('Ad');
var flsStr = ' ';
flsStr += '<' + x[0].childNodes[0].firstChild.nodeValue + x[0].childNodes[1].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[2].firstChild.nodeValue + x[0].childNodes[3].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[4].firstChild.nodeValue + x[0].childNodes[5].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[6].firstChild.nodeValue + x[0].childNodes[7].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes

.firstChild.nodeValue + x[0].childNodes[9].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[10].firstChild.nodeValue + x[0].childNodes[11].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[12].firstChild.nodeValue + x[0].childNodes[13].firstChild.nodeValue + ' ';
flsStr += '> \n';
flsStr += '<' + x[0].childNodes[14].firstChild.nodeValue + x[0].childNodes[15].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[16].firstChild.nodeValue + x[0].childNodes[17].firstChild.nodeValue + ' ';
flsStr += '/' + '> \n';
flsStr += '<' + x[0].childNodes[18].firstChild.nodeValue + x[0].childNodes[19].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[20].firstChild.nodeValue + x[0].childNodes[21].firstChild.nodeValue + ' ';
flsStr += '/' + '>';
flsStr += '<' + x[0].childNodes[22].firstChild.nodeValue + x[0].childNodes[23].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[24].firstChild.nodeValue + x[0].childNodes[25].firstChild.nodeValue + ' ';
flsStr += '>';
flsStr += '<' + x[0].childNodes[26].firstChild.nodeValue + x[0].childNodes[27].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[28].firstChild.nodeValue + x[0].childNodes[29].firstChild.nodeValue + ' ';
flsStr += '> \n';
flsStr += '<' + x[0].childNodes[30].firstChild.nodeValue + x[0].childNodes[31].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[32].firstChild.nodeValue + x[0].childNodes[33].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[34].firstChild.nodeValue + x[0].childNodes[35].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[36].firstChild.nodeValue + x[0].childNodes[37].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[38].firstChild.nodeValue + x[0].childNodes[39].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[40].firstChild.nodeValue + x[0].childNodes[41].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[42].firstChild.nodeValue + x[0].childNodes[43].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[44].firstChild.nodeValue + x[0].childNodes[45].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[46].firstChild.nodeValue + x[0].childNodes[47].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[48].firstChild.nodeValue + x[0].childNodes[49].firstChild.nodeValue + ' ';
flsStr += x[0].childNodes[50].firstChild.nodeValue + x[0].childNodes[51].firstChild.nodeValue + ' ';
flsStr += '>' + '<' + '/' + 'EMBED>' + '<' + '/' + 'Object>'
document.getElementById('flsAd').innerHTML = (flsStr);
}
// -->
</SCRIPT>
</head>
<body onLoad="importXML()">
<form runat="server">
<Div ID="flsAd"></Div>
</form>
</body>
</html>
Please refer to my questions above (Q1, Q2) as I stated this works fine in IE but not NN, FireFox etc.