日期:2014-05-16 浏览次数:20304 次
<html>
<head>
<title>js </title>
</head>
<body>
<iframe id="ifr" src="http://www.baidu.com/"; width="600" height="600"></iframe>
<script language="JavaScript">
var iframe = document.getElementById('ifr');
setTimeout(Tim(),rand(3000,9000))
function Tim(){
for(i=1;i<4;i++){
changeFrameSrc(iframe,i);
}
}
function changeFrameSrc(f,i){
var src_1 = 'http://www.163.com';
var src_2 = 'http://www.taobao.com';
var src_3 = 'http://www.qq.com';
f.src = "src_"+i;
}
function rand(min,max){
return parseInt(Math.random()*(max-min+1)+min);
}
</script>
</body>
</html>
<html>
<head>
<title>js </title>
</head>
<body>
<iframe id="ifr" src="http://www.baidu.com/"; width="600" height="600"></iframe>
<script language="JavaScript">
var iframe = document.getElementById('ifr');
//setTimeout(Tim(), rand(3000, 9000))//不要加()
setTimeout(Tim, rand(3000, 9000))
function Tim() {
changeFrameSrc(iframe, rand(1, 3));//随机一个地址
/*for (i = 1; i < 4; i++) {
changeFrameSrc(iframe, i);
}*/
}
function changeFrameSrc(f, i) {
var src_1 = 'http://www.163.com';
var src_2 = 'http://www.taobao.com';
var src_3 = 'http://www.qq.com';
f.src = eval("src_" + i)//eval得到变量
}
function rand(min, max) {
&