JS随机跳转到一个范围内的网页
来源:百度知道 编辑:UC知道 时间:2024/07/12 23:00:11
实现的效果是,比如有一百个从ID1--ID100的网页,要随机打开一个,所以先得定义一个随机参数,以下是另一
种方法,但似乎读取太慢!
<script>
function brand(a)
{
return parseInt((a)*Math.random()+1);
}
var numb;
numb=brand(5);
if (numb==1)
{
window.location = "http://www.hao123.com/1.html";
}
if (numb==2)
{
window.location = "http://www.hao123.com/2.html";
}
if (numb==3)
{
window.location = "http://www.hao123.com/3.html";
}
if (numb==4)
{
window.location = "http://www.hao123.com/4.html";
}
if (numb==
种方法,但似乎读取太慢!
<script>
function brand(a)
{
return parseInt((a)*Math.random()+1);
}
var numb;
numb=brand(5);
if (numb==1)
{
window.location = "http://www.hao123.com/1.html";
}
if (numb==2)
{
window.location = "http://www.hao123.com/2.html";
}
if (numb==3)
{
window.location = "http://www.hao123.com/3.html";
}
if (numb==4)
{
window.location = "http://www.hao123.com/4.html";
}
if (numb==
<script>
function brand(a)
{
return parseInt((a)*Math.random()+1);
}
var numb;
numb=brand(5);
window.location = "http://www.hao123.com/"+numb+".html";
</script>
function brand(a)
{
return parseInt((a)*Math.random()+1);
}
var numb;
numb=brand(5);
window.location = "http://www.hao123.com/"+numb+".html";