K
kodknackaren
Hello,
I am trying to write a javascript that will load an Adsense banner.
Everything works with the default syntax but here I want to load the ad
on certain conditions so I want a certain script for it.
In this example I have removed all conditions and am only trying to get
the banner to load but nothing happens.
Can anyone see what I have missed?
<html>
<head>
<script type="text/javascript">
function test()
{
google_ad_client = "pub-6934422475561575";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
var element=document.createElement("script");
element.setAttribute("src",
"http://pagead2.googlesyndication.com/pagead/show_ads.js");
document.body.appendChild(element);
}
</script>
</head>
<body onload="test()">
</body>
</html>
Here is the default script that works but I don't know a way to show it
conditionally other than my attempt above:
<script type="text/javascript"><!--
google_ad_client = "pub-6934422475561575";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
I am trying to write a javascript that will load an Adsense banner.
Everything works with the default syntax but here I want to load the ad
on certain conditions so I want a certain script for it.
In this example I have removed all conditions and am only trying to get
the banner to load but nothing happens.
Can anyone see what I have missed?
<html>
<head>
<script type="text/javascript">
function test()
{
google_ad_client = "pub-6934422475561575";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
var element=document.createElement("script");
element.setAttribute("src",
"http://pagead2.googlesyndication.com/pagead/show_ads.js");
document.body.appendChild(element);
}
</script>
</head>
<body onload="test()">
</body>
</html>
Here is the default script that works but I don't know a way to show it
conditionally other than my attempt above:
<script type="text/javascript"><!--
google_ad_client = "pub-6934422475561575";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>