程序员人生 网站导航

JS调用Google AdSense广告的方法

栏目:jscript时间:2013-12-06 03:14:58

  网(LieHuo.Net)教程 经过向Google AdSense 小组咨询确认,Google AdSense 允许站长使用js调用Google AdSense   广告,下面我们来讲讲具体如何调用:

  首先用记事本写一个js文件,将google广告的代码粘贴进去:查找替换所有的 "  字符,将其全部换成 "   ,然后查找所有的 /   字符将其换成   /    。

  然后,在每一行的开头加上:   document.writeln("             在结尾处加上        ");    

  这样google广告的js文件就做好了。 

  推荐非常简单的方法,直接利用HTML/JS转换工具,直接将GG广告代码转换为JS方式,工具地址:http://tool.liehuo.net/tool/html_js.asp

  然后将你的google广告的js文件上传到你的网站的一个文件夹下面。这样通过调用js文件的方法就可以使用google的广告了。

  下面是一个网站的js代码(Google_Liehuo.js): 

以下为引用的内容:
document.writeln(”<script type=”text/javascript”><!–");
document.writeln(”google_ad_client = ”pub-********************”;"); //注意修改前边的星号为你的发布商代码
document.writeln(”/* 728×90, 创建于 09-5-4 */”);
document.writeln(”google_ad_slot = ”**************”;"); //注意修改前边的星号为你的实际代码
document.writeln(”google_ad_width = 728;”);
document.writeln(”google_ad_height = 90;”);
document.writeln(”//–>”);
document.writeln(”</script>”);
document.writeln(”<script type=”text/javascript”");
document.writeln(”src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>");
document.writeln(”</script>”); 

------分隔线----------------------------
------分隔线----------------------------

最新技术推荐