doupang4126 2010-05-26 23:48
浏览 5
已采纳

如何分配在横幅集合中均匀显示每个SWF的机会?

I am working on The ausdcf.org to try adding several banner ads in swf format to the top.

Everything starts to work, but I've got several questions that need your help:

The client chose not to go with Google AdManager, but prefer a "minimal approach" to do this task.

What I am trying to do is sort of "mimicking" the way Google AdManager does for banners, that is, to split the chance of each particular swf to be shown to the visitor evenly among the banner collection.

Definitely I can add some jQuery code to do this from client-side, a random number generator and if-else statement would work - just $.load() it!

However, what if I'd like to make sure those disabled Javascript (is there any now btw?) still be able to see different swfs in each visit.

Any suggestion on how to approach this?

Many thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongren5293 2010-05-27 00:52
    关注

    The keyword you're looking for is "rotation script" or "banner rotator", and server-side is definitely the way to do something like this.

    For PHP, try:

    //available banners
    $banners = array(
       'banner1.swf',
       'banner2.swf',
       'banner3.swf'
    
       //add more here
    );
    
    //get random banner
    srand((double) microtime() * 1000000);
    $rand = rand(0,count($banners)-1);
    
    //display it
    echo $banners[$rand];
    

    This won't evenly rotate the inventory, just randomly. To rotate banners evenly, you'd have to keep track of things. Let me know if you need that and I'll post it here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办