Reputation:
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
Upvotes: 2
Views: 7453
Reputation:
I have found a solution. I must keep my javascript in a external file.
Thank you to anyone who tried to help.
Upvotes: 1
Reputation: 86413
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");
});
]]>
Upvotes: 0
Reputation: 2263
Embedded Javascript & XSLT = Insanity ;-)
The solution:
<script type="text/javascript">
//<xsl:comment><![CDATA[
$(function() {
$("div#topbanner" ).html('<img src="images/load-top.gif" class="load" />');
});
//]]></xsl:comment>
</script>
Upvotes: 2
Reputation: 5381
I've seen this when I forget to use
disable-output-escaping="yes"
in my <xslvalue-of../>
Upvotes: 0