zoukankan      html  css  js  c++  java
  • 广告 随机显示 刷新改变 cookie

    代码
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <script src="http://www.ca800.com/js/common.js"></script>
    <title>无标题文档</title>
    </head>

    <body >
    <ul >
    <li id="flash_right_ad" style="display:none">
    </li>
    </ul>


    <div id="result"></div>
    <script>
    function getRandNum(begin,end,notEqualArray){兼容notEqualArray为数字数组和单个数字


    begin
    =parseInt(begin);
    end 
    =parseInt(end);
    notEqualArray
    =notEqualArray||[];
    if(begin>end) throw new Error("begin>end");
    var stepSize= end- begin;
    var rand_num=(parseInt(begin)+(parseInt(Math.random()*parseInt(stepSize+1))));
    var notEqualStr=","+notEqualArray.toString()+',';
    if(notEqualStr.indexOf(','+rand_num+',')>-1)
    {
    rand_num
    =getRandNum(begin,end,notEqualArray);
    }
    return rand_num;
    }

    randAdRight
    =function(){
    ZhouJian.Dom.cleanWhitespace(document.getElementById(
    "flash_right_ad").parentNode)
    var len=arguments.length;
    if(len<1return;
    var stored_ad_flag= ZhouJian.Cookie.get("ad_flag")|| (arguments.length-1);
    var rand_num=getRandNum(0,len-1,stored_ad_flag);
    ZhouJian.Cookie.set(
    "ad_flag",rand_num)
    var str="";
    str
    +="<object width=\"260\" height=\"450\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">";
    str+="<param value=\""+arguments[rand_num]+"\" name=\"movie\" >";
    str
    +="<param value=\"high\" name=\"quality\">";
    str
    +="<embed width=\"260\" height=\"450\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" quality=\"high\" src=\""+arguments[rand_num]+"\"\/>";
    str+=
    "";
    str+=
    "<\/object>"

    document.getElementById(
    "flash_right_ad").style.display="";
    document.getElementById(
    "flash_right_ad").innerHTML=str;

    }

    randAdRight(
    "http://down.ca800.com/company/2010-3-1/20103113554171657.swf","http://down.ca800.com/company/2010-3-4/20103419193564574.swf","http://down.ca800.com/company/2010-3-1/20103113554171657.swf",
    "http://down.ca800.com/company/2010-3-4/20103419193564574.swf");
    </script>
    </body>
    </html>

  • 相关阅读:
    NVI模式
    C#----接口与多继承
    C#----接口与抽象类
    C#----接口的显式实现
    C# -- 继承规则
    MVC多层架构
    BootStrap2学习日记23---弹出对话框
    APP导航设计九法
    DevExpress Grid使用checkBox选中的方法
    遗漏的SQL语句
  • 原文地址:https://www.cnblogs.com/oneroom/p/randomAdNorepeat.html
Copyright © 2011-2022 走看看