var ar = [
'http://union.163.com/gs2/union/adjs/6156432/16/3?link_id=614',
'http://union.163.com/gs2/union/adjs/6156432/12/3?link_id=567',
'http://union.163.com/gs2/union/adjs/6156432/11/4?link_id=416'
];var obj = document.createElement('script');
obj.src = ar[Math.floor(Math.random() * 3)];
document.getElementsByTagName('body')[0].appendChild(obj);

解决方案 »

  1.   


    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="gb2312" />
    <title></title>
    </head>
    <body>

    <script>
    var data = [
    'http://union.163.com/gs2/union/adjs/6156432/16/3?link_id=614',
    'http://union.163.com/gs2/union/adjs/6156432/16/3?link_id=567',
    'http://union.163.com/gs2/union/adjs/6156432/16/3?link_id=416'
    ];
    // 随机 0 1 2
    var random = function(){
    return Math.floor(Math.random() * 3);
    };
    var r = random();
    var script = document.createElement('script');
    script.src = data[r];
    document.getElementsByTagName('head')[0].appendChild(script);
    </script>
    </body>
    </html>
      

  2.   

    直接将3楼的代码 复制 另存为 html 双击运行即可确定这个广告链接有效。?
      

  3.   

    吐血...折腾半天说要用php写。为什么一开始不说清楚? 
    $ar = array(
        'http://union.163.com/gs2/union/adjs/6156432/16/3?link_id=614',
        'http://union.163.com/gs2/union/adjs/6156432/12/3?link_id=567',
        'http://union.163.com/gs2/union/adjs/6156432/11/4?link_id=416'
    );
    $k=array_rand($ar,1);
    echo <<<html
    <script type="text/javascript"  src="$ar[$k]"></script>
    html;
      

  4.   


    是不是我说错了,不能用。帮我看看应该怎么写。
    http://equ8.net谢谢你了!