Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - appendChild & cloneNode >Thread Next - Re: appendChild & cloneNode Re: appendChild & cloneNodeTo: NULL Date: 6/2/2009 2:57:00 AM On Jun 1, 10:35=A0pm, Chameleon <cham_...@hotmail.com> wrote:
> The following code display a DIV#help with AJAX loaded XML inside.
> It works fine in W3C Compliant Browsers but not in IE8.
> The problem in IE8 appears in last line.
> Is there an error in my code or an IE8 incompatibility?
> Any workarounds?
> Thanks
> ---------------------------------------------------------
> function openHelp(a) {
> =A0 =A0 =A0 =A0 var obj =3D document.getElementById('help');
> =A0 =A0 =A0 =A0 obj.style.display =3D 'block';
>
> =A0 =A0 =A0 =A0 var xmlHttp =3D new XMLHttpRequest();
> =A0 =A0 =A0 =A0 xmlHttp.onreadystatechange =3D function() {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (xmlHttp.readyState =3D=3D 4)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 innerDOM(obj, xmlHttp.res=
ponseXML.documentElement);
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 xmlHttp.open("GET", 'help.php/' + a, true);
> =A0 =A0 =A0 =A0 xmlHttp.send(null);
>
> }
>
> function innerDOM(where, root) {
> =A0 =A0 =A0 =A0 for (var z =3D 0; z < root.childNodes.length; z++)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 where.appendChild(root.childNodes[z].clon=
eNode(true)); =A0// <-- HERE IS
> THE PROBLEM}
>
> --------------------------------------------------------------
Slightly superficial explanation: on Internet Explorer, the
responseXML object is an XML Document containing XML Nodes, whereas
the page into which you are trying to insert the content is an HTML
Document containing HTML Nodes; in the wacky world of Microsoft XML
and HTML have separate and incompatible implementations (even within
the browser), whereas other browsers such as Firefox use one
implementation for both cases.
You are probably better off using the responseText and innerHTML
properties, as David Mark suggests, even though it is less
satisfactory from a purist perspective :-(
Regards,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
