js代码|每次随机进入不同网页
时间:2021-08-10 22:20:38 阅读:1424
1.以下是一个随机跳转到指定网址的JavaScript代码:
<script> // 定义一个数组,包含要跳转的网址 var urls = [ "http://www.clxsite.cn/", "http://www.caihongfaka.cn/", "https://www.caihongdaishuawang.com/", "https://www.fuzhufakawang.com/" ]; // 生成一个随机数,作为数组的索引 var randomIndex = Math.floor(Math.random() * urls.length); // 获取随机的网址 var randomUrl = urls[randomIndex]; // 跳转到随机的网址 window.location.href = randomUrl; </script>
这段代码首先定义了一个包含要跳转的网址的数组,然后生成一个随机数作为数组的索引,获取随机的网址,最后使用`window.location.href`将页面跳转到随机的网址。
2.每次进入网站,自动跳转不同网页
<script language="javascript"> var arr = new Array( "https://hutoucun.cn/post/2486.html", "https://hutoucun.cn/post/2478.html", "https://hutoucun.cn/post/638.html", ); window.location.href = arr[Math.floor(Math.random() * arr.length)]; </script>
<script>
function changeurl(){
var arr = new Array(
"https://hutoucun.cn/post/2486.html",
"https://hutoucun.cn/post/2478.html",
"https://hutoucun.cn/post/638.html",
);
window.location.href = arr[Math.floor(Math.random() * arr.length)];
}
changeurl();
</script>3.
<script>
function redirectToRandomUrl(urls) {
var randomIndex = Math.floor(Math.random() * urls.length);
window.location.href = urls[randomIndex];
}
var urls = [
"http://www.clxsite.cn/",
"http://www.caihongfaka.cn/",
"https://www.caihongdaishuawang.com/",
"https://www.fuzhufakawang.com/"
];
redirectToRandomUrl(urls);
</script>

网友评论