JavaScript问题 题目要求:在网页中随机地显示五个div,用setTimeout控制,时间范围是0.5s~1s之间,当第五个div生成后,出现一个警告框。用JavaScript实现请各位高人予以指点。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript">var i=0;function init(){ var a=parseInt(500+Math.random()*500); var b=document.createElement("div"); b.style.backgroundColor="red"; b.style.width="100px"; b.style.height="100px"; b.innerHTML=i+""; document.body.appendChild(b); i++; p=window.setTimeout("init()",a); if(i==5){ stops(); alert(""); }}function stops(){ window.clearTimeout(p);}window.onload=init;</script>这样试试 刚刚学jquery谁帮我看看 没有效果 谢谢了 javascript脚本的位置 IE7的多窗口焦点转移问题 如何获取文档中指定像素的颜色 考试系统定时提交表单,时间到达临界点时出现问题!!!!! 问过无数人,现在已是千古之谜了!! 求帮忙看一段代码。关于焦点图 如何得到一个不知名单行输入框的对像句柄(js) 自动生成文本框 如何让图片自左向右滚动?我这只能做到自右向左,谢谢,急 关于汉字编码问题 正则表达式{n,m}的匹配,求解释 js 的对象几时销毁
var i=0;
function init(){
var a=parseInt(500+Math.random()*500);
var b=document.createElement("div");
b.style.backgroundColor="red";
b.style.width="100px";
b.style.height="100px";
b.innerHTML=i+"";
document.body.appendChild(b);
i++;
p=window.setTimeout("init()",a);
if(i==5){
stops();
alert("");
}
}
function stops(){
window.clearTimeout(p);
}
window.onload=init;
</script>这样试试