一段随机显示广告代码的源码

阿里妈妈实再是很下流,午夜客在BLOG右侧投放的阿里妈妈广告被强制无奈的常年显示成淘宝客的推广广告。

午夜客非常不喜欢淘宝客,丢单太严重了。

跟去妈里论坛反映,得到的结果是不可以让用户选择投放什么广告。广告完全是程序根据内容自动显示竞价广告或是淘宝客的广告来的。

午夜客非常无语这个说法。正所谓买卖公平,这都不让用户自己选择要投放什么广告了还叫什么买卖。

没办法,只有做个替换广告了,当出现了淘宝客广告时就自动替换成其它的广告。

为了避免广告显示单一,做了多个广告轮换显示。

所以就用到下面的小源码来让多套广告代码随机轮换了:

 

<script    LANGUAGE=”Javascript”>
<!–
////////////////////////////////////////////////////////
////////    广告数
num    =    7

////////    最前显示内容,代码将显示在广告代码上方.删掉代码也行.
ad1=’<FONT    color=#ff0000></FONT><br>’

////////   广告正在载入中,稍候……

theAds    =    new    Array();

theAds[1]    =    “ http://wyk.net.ru  广告内容一”;
theAds[2]    =    ” http://ai.net.ru 广告内容二”;
theAds[3]    =    ” http://wuyeke.net.ru 广告内容三”;
theAds[4]    =    ” http://jingchu.org 广告内容四”;
theAds[5]    =    ” http://tianmen.net.ru 广告内容五”;
theAds[6]    =    ” http://wuyeke.org.ru 广告内容六”;
theAds[7]    =    ” http://zz.pp.ru 广告内容七”;

sx    =    parseInt(Math.random()    *    num+    1);
document.write(ad1+theAds[sx]);
–>

</script>

 

num = 后面的数字是几就表示几个广告在theAds[X] = “广告代码X”;这里做相应增减

但确定是广告代码中不能有双引号.要用单引号.或你把这段代码的双引号改成单引号也行!!!投放某些广告联盟的“””广告代码可能会显示不了!

下面这段代码比较适合投放广告联盟的广告:

 

<html>
<head>
<title>午夜客 免费域名提供 免费空间提供</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″><style type=”text/css”>
<!–
body {
 margin-left: 0px;
 margin-top: 0px;
}
–>
</style></head>
<body>
<table cellSpacing=0 cellPadding=0 width=160 align=left
                  border=0>
                    <tr>
                      <td
                      height=115 align=”left” vAlign=middle background=images/index_22.gif>
        <div id=”divone”>
                      <table cellSpacing=0 cellPadding=0 width=160
                        align=center border=0>
                          <tr>
                            <td> 轮显第一排字 http://wyk.net.ru
                              <div align=center></div></td>
                          </tr>
          </table>  </div>
         <div id=”divtwo” >
                            <table cellSpacing=0 cellPadding=0 width=160
                        align=center border=0>
                          <tr>
                            <td> 轮显第二排字 http://ai.net.ru
                              <div align=center></div></td>
                          </tr>
           </table>
         </div>
           <div id=”divthree” >
                    <table cellSpacing=0 cellPadding=0 width=160
                        align=center border=0>
                          <tr>
                            <td> 轮显第三排字 http://jingchu.org
                              <div align=center></div></td>
                          </tr>
             </table></div>
           <div id=”divtfour” >
                      <table cellSpacing=0 cellPadding=0 width=160
                        align=center border=0>
                          <tr>
                            <td> 轮显第四排字 http://zz.pp.ru
                              <div align=center></div></td>
                          </tr>
             </table>  </div>
           <SCRIPT LANGUAGE=”JavaScript”>
//新闻轮显
function GE(a){return document.getElementById(a);}
function setwhile()
{
GE(‘divone’).style.display=’none’;
GE(‘divtwo’).style.display=”;
GE(‘divthree’).style.display=’none’;
GE(‘divtfour’).style.display=’none’;
setTimeout(“setone();”, 2000);
}
 function setone()
 {
GE(‘divone’).style.display=”;
GE(‘divtwo’).style.display=’none’;
GE(‘divthree’).style.display=’none’;
GE(‘divtfour’).style.display=’none’;
   setTimeout(“settwo();”, 2000);
 }
function settwo()
 {
GE(‘divone’).style.display=’none’;
GE(‘divtwo’).style.display=’none’;
GE(‘divthree’).style.display=”;
GE(‘divtfour’).style.display=’none’;
   setTimeout(“setthree();”, 2000);
 }
 function setthree()
 {
GE(‘divone’).style.display=’none’;
GE(‘divtwo’).style.display=’none’;
GE(‘divthree’).style.display=’none’;
GE(‘divtfour’).style.display=”;
   setTimeout(“setwhile();”, 2000);
 }
setwhile();
  </SCRIPT></td>
                    </tr>
</table>
</body>
</html>

具体演示见午夜客BLOG右侧的广告位吧!


Tags: , , , , , , , , , , ,


Comments

看看不做评论

@奔四大叔: 反对无效!

和蔼可敬的午夜大大,能不能做个友情链接呢
hao123免费收录
http://www.mfhao123.cn
你的已经加了哦

@salang: 不做CN域名的链接。抱歉!

具体要求见http://blog.wyk.net.ru/link

留下评论

(必需)

(必需)