广告联盟网

 找回密码
 注册
查看: 919|回复: 10
打印 上一主题 下一主题

Google Adsense 官方的加速显示代码的改进用法

[复制链接]
跳转到指定楼层
1#
发表于 2006-9-21 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
为了解决因部分地区网络无法连接 Google 服务器,而使得页面中的 Google Adsense 代码拖慢网页速度的问题,Google 推出了官方的加速显示代码。

所谓 Google Adsense 官方的加速显示代码,就是下面这段了: <div id=&quot;googlead&quot; width=&quot;468&quot; height=&quot;15&quot;></div>
<div id=&quot;googleadcode&quot; style=&quot;display:none&quot;>
<script type=&quot;text/javascript&quot;><!--
google_ad_client = &quot;pub-代码&quot;;
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = &quot;468x15_0ads_al_s&quot;;
google_ad_channel =&quot;&quot;;
google_page_url = document.location;
google_color_border = &quot;336699&quot;;
google_color_bg = &quot;FFFFFF&quot;;
google_color_link = &quot;336699&quot;;
google_color_url = &quot;225588&quot;;
google_color_text = &quot;000000&quot;;
//--></script>
<script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;>
</script>
</div>
<script language=&quot;javascript&quot;>
if(document.all.item(&quot;googlead&quot;) != null)
{
googlead.innerHTML = googleadcode.innerHTML
}
</script>

因为学校的公寓城用的是教育网,国外的网站连接全部被屏蔽掉了,Google 也不例外。上次就是因为网页中加了 Google Analytics 的代码,在那边一直打不开我的网站,然后就不得不忍痛割爱,摘掉了这项超极强大的统计代码。现在网页中又加入了 Google Adsense,幸好有上面这段代码,使得我的网站既能做广告,又不影响在教育网的浏览。

使用中发现通过上面方法处理的页面到 Firefox 中广告根本出不来,仔细研读代码,发现其中的 JS 用得不是很标准,于是我又对这段代码做了下面的优化:

在代码中需要加广告的地方加入: <!-- Google AdSense Start -->
<div id=&quot;gad&quot; style=&quot;width=468px;height=15px;&quot;></div>
<!-- Google AdSense End -->
然后在页面代码的最底下加入: <!-- Google AdSense Code Start -->
<div id=&quot;gadcode&quot; style=&quot;display:none&quot;>
<script type=&quot;text/javascript&quot;><!--
google_ad_client = &quot;pub-代码&quot;;
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = &quot;468x15_0ads_al_s&quot;;
google_ad_channel =&quot;&quot;;
google_page_url = document.location;
google_color_border = &quot;336699&quot;;
google_color_bg = &quot;FFFFFF&quot;;
google_color_link = &quot;336699&quot;;
google_color_url = &quot;225588&quot;;
google_color_text = &quot;000000&quot;;
//--></script>
<script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;>
</script></div>
<script type=&quot;text/javascript&quot;>
if(document.getElementById(&quot;gad&quot;) != null)
{
document.getElementById(&quot;gad&quot;).innerHTML = document.getElementById(&quot;gadcode&quot;).innerHTML;
}
</script>
<!-- Google AdSense Code End -->
11#
发表于 2006-9-22 | 只看该作者
我研究过,这个是二次显示广告,单价会低点的.........
10#
发表于 2006-9-22 | 只看该作者
用<span>标签会好一点
9#
发表于 2006-9-22 | 只看该作者
getElementById只支持 IE5.5以上版本
8#
发表于 2006-9-22 | 只看该作者
不是不允许而是不需要,我从这句代码感觉到这是很久前的东西了。
7#
发表于 2006-9-22 | 只看该作者
原帖由 小龙 于 2006-9-22 08:35 发表google_page_url = document.location; 这是什么?
现在不允许加这条代码了, gg自动识别frame的。
楼主有违规献艺
6#
发表于 2006-9-22 | 只看该作者
google_page_url = document.location; 这是什么?
5#
发表于 2006-9-22 | 只看该作者
document.getElementById(&quot;gad&quot;)这个是标准的写法

楼上说的对,也可以自己做一个预先加载广告的代码
4#
发表于 2006-9-21 | 只看该作者
根本不是官方的吧,只是先加载网页加载广告的代码
3#
发表于 2006-9-21 | 只看该作者
GG的代码难道可以自己修改了??
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|广告联盟网  

GMT, 2024-9-29 , Processed in 0.077834 second(s), 20 queries .

Powered by Discuz! X3.2

© 2005-2021 www.ggads.com GGADS 广告联盟网

快速回复 返回顶部 返回列表