I seem to be getting this weird problem in Internet explorer. I have
written a code for parsing a XML file and displaying the output. The
code works perfectly fine with ffx(Firefox).Ho wever is not working in
Internet Explorer.(I m using Internet Explorer 6.0). The code is as
follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>
<script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
djConfig="parse OnLoad:true">
</script>
<script type="text/javascript">
dojo.require("d ojo.parser");
dojo.require("d ijit.TitlePane" );
</script>
<style type="text/css">
@import "dojo-release-1.1.1/dojo/resources/dojo.css";
@import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
#output
{
width:500px;
}
</style>
<script language="javas cript">
function create_button(t itletoapply,idt oapply,cont)
{
ttltoapply = titletoapply;
ids = idtoapply;
conti = cont;
elementcreator( ids,conti);
var params = {
// Note here, when creating programmaticall y,
this is a function, not a string
open:false,
title:ttltoappl y
};
var button_dynamic = new dijit.TitlePane (
params,dojo.byI d(ids)
);
}
function elementcreator( id,content)
{
var idtoassign = id;
var contenttoassign = content;
var browser = navigator.userA gent;
if(browser.inde xOf("MSIE") != -1)
{
var diselement = document.create Element('div');
var diselementattri b = document.create Attribute('id') ;
diselementattri b.value = idtoassign;
diselement.setA ttributeNode(di selementattrib) ;
diselement.inne rHTML = contenttoassign ;
var core = document.getEle mentById('outpu t');
core.appendChil d(diselement);
}
else
{
var elem = document.create Element('div');
elem.setAttribu te('id',idtoass ign);
elem.innerHTML = contenttoassign ;
var core = document.getEle mentById('outpu t');
core.appendChil d(elem);
}
}
function createXHR()
{
try{return new XMLHttpRequest( );}catch(e){}
try { return new ActiveXObject(" Msxml2.XMLHTTP. 6.0"); } catch (e) {}
try { return new ActiveXObject(" Msxml2.XMLHTTP. 3.0"); } catch (e) {}
try { return new ActiveXObject(" Msxml2.XMLHTTP" ); } catch (e) {}
try{return new ActiveXObject(" Microsoft.XMLHT TP");}catch(e){ }
}
function sendrequest()
{
var xhr = createXHR();
xhr.open("GET", "Example1.xml", true);
xhr.onreadystat echange = function(){hand leresponse(xhr) ;}
xhr.send(null);
}
function handleresponse( xhr)
{
var response = xhr.responseXML ;
var rssentries=resp onse.getElement sByTagName("ite m");
var linku;
var title;
var idgenerated;
for (var i=0; i<rssentries.le ngth; i++){
idgenerated = "count" + i;
linku=rssentrie s[i].getElementsByT agName('link')
[0].firstChild.nod eValue;
title=rssentrie s[i].getElementsByT agName('title')
[0].firstChild.nod eValue;
//create_button(t itle,idgenerate d,linku);
elementcreator( idgenerated,tit le);
}
var display = document.getEle mentById('outpu t');
//display.innerHT ML = output;
}
function closetabs()
{
var core=document.g etElementById(" bbdy");
var child=document. getElementById( "output");
core.removeChil d(child);
}
</script>
</head>
<body class="tundra" id="bbdy">
<div id="output"></div>
<button onclick="sendre quest()">Proces s</button>
<button onclick="closet abs()">remove</button>
</body>
</html>
P.S: The dojo part of the script can be commented as it has no
relation with the working of logic
The xml file for this is as follows
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="0.91">
<channel>
<title>JavaScri ptKit.com</title>
<link>http://www.javascriptk it.com</link>
<description>Ja vaScript tutorials and over 400+ free scripts!</
description>
<language>en</language>
<item>
<title>Docume nt Text Resizer</title>
<link>http://www.javascriptkit.com/script/script2/
doctextresizer. shtml</link>
<description>Th is script adds the ability for your users to toggle
your webpage's font size, with persistent cookies then used to
remember the setting</description>
</item>
<item>
<title>JavaScri pt Reference- Keyboard/ Mouse Buttons Events</title>
<link>http://www.javascriptk it.com/jsref/eventkeyboardmo use.shtml</
link>
<description>Th e latest update to our JS Reference takes a hard look
at keyboard and mouse button events in JavaScript, including the
unicode value of each key.</description>
</item>
<item>
<title>Dynamica lly loading an external JavaScript or CSS file</title>
<link>http://www.javascriptk it.com/javatutors/loadjavascriptc ss.shtml</
link>
<description>Ex ternal JavaScript or CSS files do not always have to be
synchronously loaded as part of the page, but dynamically as well. In
this tutorial, see how.</description>
</item>
</channel>
</rss>
Please can anyone provide me solution for this prob