javaScript 数组随机跳转

<script type="text/javascript">
    var myarr = new Array(); //javaScript 的函数区分大小写,如果这里写在 new array 执行就会出错。
    myarr[0] = "http://www.baidu.com/";
    myarr[1] = "http://www.sogou.com/";
    alert(myarr[1]);
    alert(Math.floor(Math.random()*myarr.length)); //这个Math也是;
    window.location.href = myarr[Math.floor(Math.random()*myarr.length)];
</script>

我使用的是 1st JavaScript Editor Pro 5.1 代码提示不是很好,还要找更好的开发工具。

posted @ 2013-01-22 20:05  stma  阅读(190)  评论(0)    收藏  举报