I have been trying to insert some ads on my website. I have Google AdSense's script, but when I insert it and try to display the page, it displays till the point where the script is put, and nothing below where the script is put (although the HTML is there if I browse it with Firefox!).
I have tried the same on a static page locally and it works, but seems like the moment I put it in my XSLT file, it makes everything below disappear.
First I realized about the closing tags and XSLT. It was in fact closing the scripts with "/>" instead of "</script>".
Having solved that I know see I can't get it to display the comment on the first javacript properly. With your solution, I get nearly what I need. This is the output:
I would need to substitute those "//" with respective "<!--" and "//-->", but I don't know how to do that as if I put them explicitly, XSLT takes them as comments and doesn't include them, which I need. Any idea?
It may aslo be that since there is no data between your second Script tag and closing of that tag it is not rendering the page properly and trying to put everything inside of that script tag. That can be solved by:
Google AdSense script makes XSLT to not work
Hello!
I have been trying to insert some ads on my website. I have Google AdSense's script, but when I insert it and try to display the page, it displays till the point where the script is put, and nothing below where the script is put (although the HTML is there if I browse it with Firefox!).
I have tried the same on a static page locally and it works, but seems like the moment I put it in my XSLT file, it makes everything below disappear.
The script is, just in case:
I have placed it in several areas of the page... inside a div, outside a div, etc... but the result is the same.
Any idea why this can be happening? Thanks!
Is it getting stripped out because of the comment tags? Will this work?
Hi jc and thanks for answering!
First I realized about the closing tags and XSLT. It was in fact closing the scripts with "/>" instead of "</script>".
Having solved that I know see I can't get it to display the comment on the first javacript properly. With your solution, I get nearly what I need. This is the output:
I would need to substitute those "//" with respective "<!--" and "//-->", but I don't know how to do that as if I put them explicitly, XSLT takes them as comments and doesn't include them, which I need. Any idea?
Thanks a lot!
you can just try to wrap the entire thing in a CDATA
<![CDATA[
<script type="text/javascript">
google_ad_client = "pub-XXXXXXXXXX";
/* 728x15, created 8/27/10 */
google_ad_slot = "XXXXXX";
google_ad_width = 728;
google_ad_height = 15;
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]>
It may aslo be that since there is no data between your second Script tag and closing of that tag it is not rendering the page properly and trying to put everything inside of that script tag. That can be solved by:
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
Hi FreedomChicken!
Trying your solution it outputs:
I have been able to solve it using:
I know it's not too elegant... but it's the only thing I've been able to come up with to right now =).
If anybody has something better... glad to hear about it.
Thanks both for helping! Cheers!
Oh yeah, forgot it does that. Another solution could be to simply throw it into aDictionary item and reference it like:
<xsl:value-of select="umbraco.library:GetDictionaryItem('googleScript')" disable-output-escaping="yes" />
Oh yeah, forgot it does that. Another solution could be to simply throw it into aDictionary item and reference it like:
<xsl:value-of select="umbraco.library:GetDictionaryItem('googleScript')" disable-output-escaping="yes" />
Hi Jacobo,
The "correct" (and clean/elegant) way to do this, is to use the xsl:comment instruction:
<script type="text/javascript"> <xsl:comment><![CDATA[ google_ad_client = "pub-XXXXXXXXXX"; /* 728x15, created 8/27/10 */ google_ad_slot = "XXXXXX"; google_ad_width = 728; google_ad_height = 15; //]]></xsl:comment> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><xsl:comment /></script>
/Chriztian
is working on a reply...