PDA

View Full Version : Adsense code in variable



minusp
15 May 2009, 08:53 AM
hello

can anyone help me on this script?
this is my script



<script type="text/javascript">
<!--
function fc() {
var tt = '
<script type="text/javascript"><!--
google_ad_client = "pub-2606800903002383";
/* Download Butt 234x60, created 5/14/09 */
google_ad_slot = "0574420856";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
document.getElementById("dl").innerHTML = tt;
}

//-->
</script>


<div id="dl">&nbsp;<h3 style="font-size: 24pt;" id="zeit">dd</h3></div>

<script type="text/javascript">
<!--
fc();
//-->
</script>

in a part of my script I want to add google adsense code in "tt" variable
but I get error when I add the google code into that .
I think //--> in the google code makes problem.
can you add the adsense code in the tt variable without any error?
please help me.

Regards

omnicity
04 Jun 2009, 08:57 AM
I'm not quite clear on why you are trying to do this, and not quite certain that Google will approve, but actually it is probably the </script> within the string that is causing the problem.
The best way around that is to split it and concatenate like so:

var thisVar = "</scr" + "ipt>"