Problem with .JS file

Hi all,
              I've a question which is related with JavaScript and XML. I hope that you can give me a solution for this question.
              I am posting 3 files... one is html (testing.html)... second is .js file (my.js) and third one is a XML file (my.xml).

When I test html using IE, it's working fine and give me proper output. But using Netscape (6.1), it gives me "undefined".

Can any one please help me in finding out the problem?.

Here are the files..............


<<<<<testing.html>>>>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>Untitled</title>
</head>
<script language="javascript" src="my.js">
</script>
<body>

<script language="javascript"> document.write(Banner_Show());</script>

</body>
</html>

<<<<my.js>>>>

function Banner_Show(){
    var banner;
    var i=""+Math.random();
    var j = parseInt(i.substring(2,3));
    var k = parseInt(i.substring(3,4));
    var banner_id=j+k;
    if(banner_id==0){banner_id=1}
    if(banner_id>14){banner_id=banner_id-10}
    var xmlDoc,x,xml_banner_id,xml_banner_image,xml_banner_link,xml_banner_name;
 var cardsxml="my.xml";
 if(window.ActiveXObject){
 ieXML(); }
 else { nsXML(); }
 function ieXML(){ 
 xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
 xmlDoc.async = false;
 xmlDoc.load(cardsxml);
 x = xmlDoc.getElementsByTagName('Banners');
 banner=getbanner();  
 }
 function nsXML() { 
 xmlDoc = document.implementation.createDocument("", "", null);
 xmlDoc.addEventListener("load",init1,false);
 xmlDoc.load(cardsxml);
 function init1() {
 x = xmlDoc.getElementsByTagName('Banners');
 //alert(currentcardid);
 banner=getbanner();  
 }}
 function getbanner(){
  for(i=0;i<x.length;i++){
xml_banner_id=x.item(i).getElementsByTagName('Banner_Id').item(0).firstChild.nodeValue;
     if(xml_banner_id==banner_id){
xml_banner_name=x.item(i).getElementsByTagName('Banner_Name').item(0).firstChild.nodeValue;          xml_banner_image=x.item(i).getElementsByTagName('Banner_Image').item(0).firstChild.nodeValue;
xml_banner_link=x.item(i).getElementsByTagName('Banner_Link').item(0).firstChild.nodeValue;
break;
   }
  }
  var str="<a href='"+xml_banner_link+"' target='new'><img src='"+xml_banner_image+"' width='468' height='60' alt='"+xml_banner_name+"' border='0'></a>";
      return str;
 }  
return banner; 
}

<<<my.xml>>>
<?xml version="1.0" encoding="UTF-8"?>

<Banner_Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="banner.xsd">

<Banners>

<Banner_Id>1</Banner_Id>

<Banner_Name>Sterling Bank</Banner_Name>

<Banner_Image>sterling_banner.gif</Banner_Image>

<Banner_Link>http://service.bfast.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>2</Banner_Id>

<Banner_Name>Yellow Credit card</Banner_Name>

<Banner_Image>Fusion_Smart_Fleet_banner.gif</Banner_Image>

<Banner_Link>http://service.bfast.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>3</Banner_Id>

<Banner_Name>ePlatinum Offer</Banner_Name>

<Banner_Image>e-platinum_fleet_banner.gif</Banner_Image>

<Banner_Link>http://service.bfast.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>4</Banner_Id>

<Banner_Name>Titanium Rebate Card</Banner_Name>

<Banner_Image>titanium_fleet_banner.gif</Banner_Image>

<Banner_Link>http://service.bfast.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>5</Banner_Id>

<Banner_Name>Chase Platinum</Banner_Name>

<Banner_Image>chase_platinum_banner1.gif</Banner_Image>

<Banner_Link>http://click.linksynergy.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>6</Banner_Id>

<Banner_Name>Chase Platinum</Banner_Name>

<Banner_Image>chase_plat_banner_2.gif</Banner_Image>

<Banner_Link>http://click.linksynergy.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>7</Banner_Id>

<Banner_Name>Chase Continental</Banner_Name>

<Banner_Image>chase_cont_banner.gif</Banner_Image>

<Banner_Link>http://click.linksynergy.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>8</Banner_Id>

<Banner_Name>Shell Fuel Saving</Banner_Name>

<Banner_Image>chase_shell.gif</Banner_Image>

<Banner_Link>http://click.linksynergy.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>9</Banner_Id>

<Banner_Name>NextCard Visa</Banner_Name>

<Banner_Image>next_card_banner.gif</Banner_Image>

<Banner_Link>http://www.nextcard.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>10</Banner_Id>

<Banner_Name>American Express Cash Rebate</Banner_Name>

<Banner_Image>amex_plat_cash_rebate_banner.gif</Banner_Image>

<Banner_Link>http://click.linksynergy.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>11</Banner_Id>

<Banner_Name>www.conseco.com</Banner_Name>

<Banner_Image>image139.gif</Banner_Image>

<Banner_Link>http://www.qksrv.net</Banner_Link>

</Banners>

<Banners>

<Banner_Id>12</Banner_Id>

<Banner_Name>www.conseco.com</Banner_Name>

<Banner_Image>image132.gif</Banner_Image>

<Banner_Link>http://www.qksrv.net</Banner_Link>

</Banners>

<Banners>

<Banner_Id>13</Banner_Id>

<Banner_Name>NextCard Visa</Banner_Name>

<Banner_Image>next_card_banner1.gif</Banner_Image>

<Banner_Link>http://www.nextcard.com</Banner_Link>

</Banners>

<Banners>

<Banner_Id>14</Banner_Id>

<Banner_Name>NextCard Visa</Banner_Name>

<Banner_Image>next_card_banner2.gif</Banner_Image>

<Banner_Link>http://www.nextcard.com</Banner_Link>

</Banners>

</Banner_Record>


with best regards,
Pranav Kumar
Software Engineer
Informica Inc.
www.Informica.com

"Let us be greatful to people who make us happy - they are the charming gardeners who make our souls blossom."

Received on Wednesday, 3 October 2001 15:43:45 UTC