使用JS调用Adsense代码有如下优势:

1、减少生成页面的大小;

2、当你想更换广告样式的时候,不必重新生成所有页面。
使用使用JS调用Adsense代码的方法:

1、使用html/js转换器将adsense广告代码转换成js格式(以下是样本)

document.writeln("<script type="text/javascript"><!–");
document.writeln("google_ad_client = "pub-************";");
document.writeln("google_ad_width = 468;");
document.writeln("google_ad_height = 15;");
document.writeln("google_ad_format = "468×15_0ads_al_s";");
document.writeln("google_ad_channel = "";");
document.writeln("google_color_border = "FFFFFF";");
document.writeln("google_color_bg = "FFFFFF";");
document.writeln("google_color_link = "3FA600";");
document.writeln("google_color_text = "000000";");
document.writeln("google_color_url = "008000";");
document.writeln("//–></script>");
document.writeln("<script type="text/javascript"");
document.writeln("  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">");
document.writeln("</script>");

2、将这些js代码保存在一个js文件中(例如ggad.js,保存于网站的js文件夹)

3、在需要放置广告的地方使用如下代码调用:

<div><script language="JavaScript" src="/js/ggad.js" type="text/javascript"></script></div>