全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2499|回复: 8

判断次数 平均跳转的代码 有木有?》?????????...

[复制链接]
发表于 2013-4-26 18:38:07 | 显示全部楼层 |阅读模式
go.html?go.php?go.asp

跳转目标站3个a.com b.com c.com

打开100次 平均分配到每个站30次的 跳转代码有木有?
发表于 2013-4-26 19:29:42 | 显示全部楼层
简单的用random随机跳转吧,概率一样的
 楼主| 发表于 2013-4-26 20:10:09 | 显示全部楼层
怎么写 求教!!
发表于 2013-4-26 20:12:51 | 显示全部楼层
tongqiu
发表于 2013-4-26 20:19:02 | 显示全部楼层
我不说。。
 楼主| 发表于 2013-4-26 21:48:58 来自手机 | 显示全部楼层
真心求
发表于 2013-4-27 08:12:26 | 显示全部楼层
<?php

$url[0] = "http://www.hao123.com/";
$url[1] = "http://www.baidu.com/ ";
$url[2] = "http://www.google.cn/ ";

srand ((double)microtime()*1000000);
$randomnum = rand(0, count($url)-1);
header ("Location: $url[$randomnum]");
?>


srand ((double)microtime()*1000000);//这句是取一个随机数种子,产生随机数用的
$randomnum = rand(0, count($url)-1);//这句是产生一个0和url数量-1之间的随机数,也就是上面的地址数组的下标
header ("Location: $url[$randomnum]");//这句是跳转指令
发表于 2013-4-27 09:49:44 | 显示全部楼层
本帖最后由 八戒 于 2013-4-27 09:50 编辑
  1. <html>
  2. <head>
  3.     <title></title>
  4.     <script type="text/javascript">
  5.         function Redirect() {
  6.             var i = Math.floor(Math.random() * 3 + 1);
  7.             var url = "http://a.hostloc.com";
  8.             switch (i) {
  9.                 case 1:
  10.                     break;
  11.                 case 2:
  12.                     url = "http://b.hostloc.com";
  13.                     break;
  14.                 case 3:
  15.                     url = "http://c.hostloc.com";
  16.                     break;
  17.                 default:
  18.             }
  19.             window.location.href = url;
  20.         }
  21.     </script>
  22. </head>
  23. <body onload="Redirect()">
  24. </body>
  25. </html>
复制代码
js随机跳转
发表于 2013-4-27 09:52:18 | 显示全部楼层
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3.     <title></title>
  4.     <script type="text/javascript">
  5.         function Redirect() {
  6.             var a = 0, b = 0, c = 0;
  7.             for (var i = 0; i < 100; i++) {
  8.                 var r = Math.floor(Math.random() * 3 + 1);
  9.                 var url = "http://a.hostloc.com";
  10.                 switch (r) {
  11.                     case 1:
  12.                         a++;
  13.                         break;
  14.                     case 2:
  15.                         url = "http://b.hostloc.com";
  16.                         b++;
  17.                         break;
  18.                     case 3:
  19.                         url = "http://c.hostloc.com";
  20.                         c++;
  21.                         break;
  22.                     default:
  23.                 }
  24.                 //window.location.href = url;
  25.             }
  26.             document.write("跳a " + a + "次  " + "跳b " + b + "次  " + "跳c " + c + "次  ");
  27.         }
  28.     </script>
  29. </head>
  30. <body onload="Redirect()">
  31. </body>
  32. </html>
复制代码
测试结果
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-7 02:00 , Processed in 0.426714 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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