JS小程序(急!!!) 本帖最后由 zj3701838 于 2009-12-23 18:27:55 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>New Document</title><script type="text/javascript"><!--window.onload = function(){ var array = ["a","b","c","d","e","f","g"]; for(var i = 0,len = array.length; i < len; i++){ var index = Math.round((array.length-1) * Math.random());//得到数组长度范围内的整数 document.write(array[index]); array.splice(index,1);//删除index位置的元素,只删一个 } document.write("<br>"); document.write("length:" + array.length);//最后的数组长度为零了}//--></script></head><body></body></html>楼主试试吧,量身定做!花了俺二十分钟!! 在原来的基础上改一下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>New Document </title> <script type="text/javascript"> <!-- var _array = ["a", "b", "c", "d", "e", "f", "g"]; function getValue() { if (_array.length == 0) { alert("Array length is zero!"); return; } var result = document.getElementById('result'), index = Math.round((_array.length - 1) * Math.random()); //得到数组长度范围内的整数 result.innerText += (result.innerText == '' ? '' : ',') + _array[index]; _array.splice(index, 1); //删除index位置的元素,只删一个 } //--> </script> </head> <body> <div id="result"></div> <input type="button" value="GetValue" onclick="getValue()" /></body> </html> 求实现一功能 正则表达式分组 WebBrowser控件中的javascript代码怎么调试? 我编不出来,第二个图片要跟着第一个图片而动 如何让文本域获取点击对象的内容 被jquery雷得外焦内嫩…… 关于JS的THIS 郁闷!发了三次帖,分都散完了,都得不到满意的答案。难道真没人回答吗!(java jsp asp各发一次) 目前市场分额 排在前4位的浏览器 都是什么? HTML标记的id能作为参数传递吗? 请javascript高手帮忙看一下 为什么子导航的链接会无效? window.opener =null; window.close(); 导致两个窗口都关闭!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Document</title>
<script type="text/javascript">
<!--
window.onload = function(){
var array = ["a","b","c","d","e","f","g"];
for(var i = 0,len = array.length; i < len; i++){
var index = Math.round((array.length-1) * Math.random());//得到数组长度范围内的整数
document.write(array[index]);
array.splice(index,1);//删除index位置的元素,只删一个
}
document.write("<br>");
document.write("length:" + array.length);//最后的数组长度为零了
}
//-->
</script>
</head>
<body></body>
</html>
楼主试试吧,量身定做!花了俺二十分钟!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Document </title>
<script type="text/javascript">
<!--
var _array = ["a", "b", "c", "d", "e", "f", "g"];
function getValue() {
if (_array.length == 0) {
alert("Array length is zero!");
return;
} var result = document.getElementById('result'),
index = Math.round((_array.length - 1) * Math.random()); //得到数组长度范围内的整数
result.innerText += (result.innerText == '' ? '' : ',') + _array[index];
_array.splice(index, 1); //删除index位置的元素,只删一个
}
//-->
</script>
</head>
<body>
<div id="result"></div>
<input type="button" value="GetValue" onclick="getValue()" />
</body>
</html>