[求助]各位大虾看看这段代码 为什么运行的时候浏览器会死啊?在线等 进就有分 while(1)//你的条件永远为真,怎么能不挂了; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你首先要考虑,什么时候才能跳到break去,在过去之前,浏览器会是什么样的状态。 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>test</title></head><body><script language="javascript"><!--var records = [ "第一条", "第二条", "第三条", "第四条", "第五条", "第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];var ids = "";while(1){var id = parseInt(Math.random()*records.length) + "";if( id <10){id=(id.length==1)?("0"+id):idif( ids.indexOf(id) == -1 )ids+="0"+id+"";}else{id=(id.length==1)?("0"+id):idif( ids.indexOf(id) == -1 )ids+=id+"";}document.writeln(id)document.writeln(ids)if(ids.length>=records.length*2)break;}document.write(ids);for(i=0;i<ids.length;i=i+2){var n=ids.charAt(i)+ids.charAt(i+1);n=n*10;rec = records[n/10];document.write(rec);document.write("<br/>");}//--></script></body></html> hbhbhbhbhb1021 上面还是会显示很多undefined呀 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>test</title></head><body><script language="javascript"><!--var records = [ "第一条", "第二条", "第三条", "第四条", "第五条", "第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];while(records.length!=2){var id = parseInt(Math.random()*records.length);document.write(records[id])records=(records.slice(0,id).join(",")+","+records.slice(id+1).join(",")).split(",")}var id=Math.floor(Math.random())document.write(records[id])document.write((id==0)?records[1]:records[0])//--></script></body></html> <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>test</title></head><body><script language="javascript"><!--var records = [ "第一条", "第二条", "第三条", "第四条", "第五条","第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];var ids = "";while(1){var id = parseInt(Math.random()*records.length) + "";if( id <10){id=(id.length==1)?("0"+id):idif( ids.indexOf(id) == -1 )ids+="0"+id+"";}else{id=(id.length==1)?("0"+id):idif( ids.indexOf(id) == -1 )ids+=id+"";}if(ids.length>=records.length*2)break;}document.write(ids);document.write("<br/>");for(i=0;i<ids.length;i=i+2){var n=ids.charAt(i)+ids.charAt(i+1);n=n*10;rec = records[n/10];document.write(rec);document.write("<br/>");}//--></script></body></html> </head><body><script language="javascript"><!--var records = [ "第一条<br>", "第二条<br>", "第三条<br>", "第四条<br>", "第五条<br>", "第六条<br>", "第七条<br>", "第八条<br>", "第九条<br>", "第十条<br>", "第十一条<br>", "第十二条<br>", "第十三条<br>", "第十四条<br>", "第十五条<br>"];while(records.length!=2){var id = parseInt(Math.random()*records.length);document.write(records[id])records=(records.slice(0,id).join(",")+","+records.slice(id+1).join(",")).split(",")}var id=Math.floor(Math.random())document.write(records[id])document.write((id==0)?records[1]:records[0])//--></script></body></html> js的原型方法可以直接调用! js读取指定路径下xml文件 拒绝访问 这段代码有什么不兼容其他浏览器的地方吗 关于ExtJs3.2.0版本中的ownerCt 面试题 请问大家是用什么软件写 API 文档啊?谢谢。 js循环显示对象id问题 这几天想找工作,看看这个作品够不够格? 急问! 怎么告诉后台我的点击提示框 在网上找了一个通用表单验证函数挺不错的,把代码贴出来,请问哪位高手能补充一下,谢谢 哪个编辑器能支持javascript的智能联想……
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
</head><body>
<script language="javascript">
<!--
var records = [ "第一条", "第二条", "第三条", "第四条", "第五条", "第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];
var ids = "";
while(1)
{
var id = parseInt(Math.random()*records.length) + "";
if( id <10)
{
id=(id.length==1)?("0"+id):id
if( ids.indexOf(id) == -1 )
ids+="0"+id+"";
}
else
{
id=(id.length==1)?("0"+id):id
if( ids.indexOf(id) == -1 )
ids+=id+"";
}
document.writeln(id)
document.writeln(ids)
if(ids.length>=records.length*2)
break;
}
document.write(ids);
for(i=0;i<ids.length;i=i+2)
{
var n=ids.charAt(i)+ids.charAt(i+1);
n=n*10;
rec = records[n/10];
document.write(rec);
document.write("<br/>");
}
//-->
</script>
</body>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
</head><body>
<script language="javascript">
<!--
var records = [ "第一条", "第二条", "第三条", "第四条", "第五条", "第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];while(records.length!=2)
{
var id = parseInt(Math.random()*records.length);
document.write(records[id])
records=(records.slice(0,id).join(",")+","+records.slice(id+1).join(",")).split(",")
}
var id=Math.floor(Math.random())
document.write(records[id])
document.write((id==0)?records[1]:records[0])
//-->
</script>
</body>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
</head><body>
<script language="javascript">
<!--
var records = [ "第一条", "第二条", "第三条", "第四条", "第五条",
"第六条", "第七条", "第八条", "第九条", "第十条", "第十一条", "第十二条", "第十三条", "第十四条", "第十五条"];
var ids = "";
while(1)
{
var id = parseInt(Math.random()*records.length) + "";
if( id <10)
{
id=(id.length==1)?("0"+id):id
if( ids.indexOf(id) == -1 )
ids+="0"+id+"";
}
else
{
id=(id.length==1)?("0"+id):id
if( ids.indexOf(id) == -1 )
ids+=id+"";
}
if(ids.length>=records.length*2)
break;
}
document.write(ids);
document.write("<br/>");
for(i=0;i<ids.length;i=i+2)
{
var n=ids.charAt(i)+ids.charAt(i+1);
n=n*10;
rec = records[n/10];
document.write(rec);
document.write("<br/>");
}
//-->
</script>
</body>
</html>
<script language="javascript">
<!--
var records = [ "第一条<br>", "第二条<br>", "第三条<br>", "第四条<br>", "第五条<br>", "第六条<br>", "第七条<br>", "第八条<br>", "第九条<br>", "第十条<br>", "第十一条<br>", "第十二条<br>", "第十三条<br>", "第十四条<br>", "第十五条<br>"];while(records.length!=2)
{
var id = parseInt(Math.random()*records.length);
document.write(records[id])
records=(records.slice(0,id).join(",")+","+records.slice(id+1).join(",")).split(",")
}
var id=Math.floor(Math.random())
document.write(records[id])
document.write((id==0)?records[1]:records[0])
//-->
</script>
</body>
</html>