全球主机交流论坛

标题: 判断次数 平均跳转的代码 有木有?》?????????... [打印本页]

作者: 有容乃大    时间: 2013-4-26 18:38
标题: 判断次数 平均跳转的代码 有木有?》?????????...
go.html?go.php?go.asp

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

打开100次 平均分配到每个站30次的 跳转代码有木有?
作者: 八戒    时间: 2013-4-26 19:29
简单的用random随机跳转吧,概率一样的
作者: 有容乃大    时间: 2013-4-26 20:10
怎么写 求教!!
作者: mike    时间: 2013-4-26 20:12
tongqiu
作者: onepeople    时间: 2013-4-26 20:19
我不说。。
作者: 有容乃大    时间: 2013-4-26 21:48
真心求
作者: icebin    时间: 2013-4-27 08:12
<?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
本帖最后由 八戒 于 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://443502.xyz";
  8.             switch (i) {
  9.                 case 1:
  10.                     break;
  11.                 case 2:
  12.                     url = "http://443502.xyz";
  13.                     break;
  14.                 case 3:
  15.                     url = "http://443502.xyz";
  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
  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://443502.xyz";
  10.                 switch (r) {
  11.                     case 1:
  12.                         a++;
  13.                         break;
  14.                     case 2:
  15.                         url = "http://443502.xyz";
  16.                         b++;
  17.                         break;
  18.                     case 3:
  19.                         url = "http://443502.xyz";
  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>
复制代码
测试结果




欢迎光临 全球主机交流论坛 (https://443502.xyz/) Powered by Discuz! X3.4