Good day, I have stumbled upon a bug or some strange behaviour and I can't find the solution anywhere.
I use XSLT to display HTML from a XML document. Inside that stylehsheet, I use javascript/jQuery to add some contents. But apparently you can not append anything but texts to any container.
<script type="text/javascript">
<![CDATA[
$(function() {
$("div#topbanner" ).html('<img src="images/load-top.gif" class="load" />');
});
]]>
It's working perfectly under Firefox but with IE7, after the codes execution, only the unrendered HTML appears into my DIV. Like if the <>
got replaced by > <
respectively.
To make it work under IE7, I must take out the CDATA tag but doing so, Firefox do not render it.
Is there a way to make the information into the html method execute as html code?
Thank you in advance
Good day, I have stumbled upon a bug or some strange behaviour and I can't find the solution anywhere.
I use XSLT to display HTML from a XML document. Inside that stylehsheet, I use javascript/jQuery to add some contents. But apparently you can not append anything but texts to any container.
<script type="text/javascript">
<![CDATA[
$(function() {
$("div#topbanner" ).html('<img src="images/load-top.gif" class="load" />');
});
]]>
It's working perfectly under Firefox but with IE7, after the codes execution, only the unrendered HTML appears into my DIV. Like if the <>
got replaced by > <
respectively.
To make it work under IE7, I must take out the CDATA tag but doing so, Firefox do not render it.
Is there a way to make the information into the html method execute as html code?
Thank you in advance
Share Improve this question asked Oct 1, 2009 at 17:01 Steve ThomasSteve Thomas 1- "into the html method".. html method means the jQuery.html method. The equivalent of innerHTML – Steve Thomas Commented Oct 1, 2009 at 20:25
4 Answers
Reset to default 2Embedded Javascript & XSLT = Insanity ;-)
The solution:
<script type="text/javascript">
//<xsl:ment><![CDATA[
$(function() {
$("div#topbanner" ).html('<img src="images/load-top.gif" class="load" />');
});
//]]></xsl:ment>
</script>
I have found a solution. I must keep my javascript in a external file.
Thank you to anyone who tried to help.
I've seen this when I forget to use
disable-output-escaping="yes"
in my <xslvalue-of../>
What happens if you try this?
<![CDATA[
$(function() {
$("<img>").addClass("load").attr("src","images/load-top.gif").appendTo("div#topbanner");
});
]]>
or if that still doesn't work... try this method
<![CDATA[
$(function() {
myimg = new Image();
$(myimg).addClass("load").attr("src","images/load-top.gif").appendTo("div#topbanner");
});
]]>