Question

I have my code working fine upto IE version 9. But breaking in IE 10 and mozilla and chrome.

After doing some firebugging, I found that it is due to problem in JS not working.

Here is the code :

function FillAlbumList()
{
    var tagNameTest = ''AlbumTable'';
    var dsRoot = objXMLHTTP.responseXML.documentElement;
    var tagname = dsRoot.getElementsByTagName(tagNameTest);
    var optEquipment = dsRoot.getElementsByTagName("AlbumTable");
    var tblAlbumList = document.getElementById('tblAlbumList').getElementsByTagName("tbody")[0];
    var rows = tblAlbumList.rows.length;
    var tblID = document.getElementById('dlOptFeature').getElementsByTagName("tbody")[0];
    var optArray = new Array();

    if(tagname.context.childNodes(0) != null)
    {
        gTotalAlbumCount = tagname.context.childNodes(0).parentNode.childNodes.length;
        // find the first album ID from list of Albums
        fstID = dsRoot.getElementsByTagName("fstAlbumID").context.childNodes(0).childNodes(1).text;
        // find the first album name from list of Albums
        fstName = dsRoot.getElementsByTagName("fstAlbumName").context.childNodes(0).childNodes(0).text;
        // loop through each node from XML object and populate value inside the table.
        for(var i=0;i<tagname.context.childNodes(0).parentNode.childNodes.length;i++)
        {
            if (tagname.context.childNodes(i).tagName == "AlbumTable")

=========================

Here dsRoot is :

<Album>

<AlbumTable>
<AlbumName>1B0EE6DBB8FE_18-20-25</AlbumName>
<AlbumId>3</AlbumId>
<UploadedDate>12/3/2013 6:20:48PM</UploadedDate>
<TotalImages>10</TotalImages>
<RemainingImages>10</RemainingImages>
</AlbumTable>

<AlbumTable>
<AlbumName>1B0EE6DBB8FE_18-01-32</AlbumName>
<AlbumId>2</AlbumId>
<UploadedDate>12/3/2013 6:02:01 PM</UploadedDate>
<TotalImages>10</TotalImages>
<RemainingImages>10</RemainingImages>
</AlbumTable>

<fstAlbumID>3</fstAlbumID>
<fstAlbumName>1B0EE6DBB8FE_18-20-25</fstAlbumName>

</Album>

=========================

The code is breaking after :

tagname.context.childNodes(0) => tagname.context is undefined.

I changed this to : tagname(0), and it worked in IE 10, but it then did not work in IE8.

Any suggestion how should move ahead with the changes here to make it work everywhere.

Was it helpful?

Solution

target ie10 with conditional compilation and use the code that works for ie10. use the prior code for below 10. not sure how that will help with gecko and webkit though...

@cc condional compilation reference: http://msdn.microsoft.com/en-us/library/ie/8ka90k2e(v=vs.94).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top