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);
'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);
<!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>
$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;
是不是我说错了,不能用。帮我看看应该怎么写。
http://equ8.net谢谢你了!