关键词搜索

源码搜索 ×
×

百度广告联盟代码优化

发布2012-03-09浏览5473次

详情内容

作为一个小网站,在页面上放置各种广告是理所当然的事情。我们用百度联盟。以前是google的adsense。google在天朝自宫,自绝于中国人民以后,就貌似只能挑百度了。

然后作为一个小网站,在页面上放置10个8个广告也是理所当然的事。这意味着每个页面要放置10个8个<script>,再加上其他的脚本链接、CSS链接、图片,哇,打开你这个页面,一大堆请求。就好比娶一个老婆,还附带了几个跟前夫生的小孩,以及家族里三姑六婆,恶心吧。这是我们做破网站的大忌。

10月革命一声炮响,百度为我们准备了一条优化的语句,就是不管你在页面放置多少个百度广告联盟代码,都可以包含在一次请求中。代码如下:

<script>BAIDU_CLB_preloadSlots("https://cdn.jxasp.com:9143/image/213888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/214888", "https://cdn.jxasp.com:9143/image/214888", "317888","https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/267888");</script>
里面的数字是广告的ID。


格式如下:

  1. <head><title>床上的美女</title>
  2. <script type='text/javascript' src='http://cbjs.baidu.com/js/m.js'></script>
  1. <script>BAIDU_CLB_preloadSlots("https://cdn.jxasp.com:9143/image/213888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/214888", "https://cdn.jxasp.com:9143/image/214888", "317888","https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/216888", "https://cdn.jxasp.com:9143/image/267888");</script>
  2. <link href="/css/default.css?ver=120308" rel="stylesheet" type="text/css">
  3. </head>

  1. <body>
  2. <div>
  3. <table id="ms_tbAd" style="border:none;"><tr>
  4. <td><script type="text/javascript">BAIDU_CLB_fillSlot("https://cdn.jxasp.com:9143/image/216888");</script></td>
  5. <td><script type="text/javascript">BAIDU_CLB_fillSlot("https://cdn.jxasp.com:9143/image/216888");</script></td>
  6. <td><script type="text/javascript">BAIDU_CLB_fillSlot("https://cdn.jxasp.com:9143/image/216988");</script></td>
  7. </tr>
  8. </table>
  9. </div>
  10. </body>

当然,如果仅有一个 BAIDU_CLB_fillSlot,那么这条一次请求语句就无所谓写不写了。



相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载