js代码|每次随机进入不同网页

时间:2021-08-10 22:20:38   阅读:704

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`将页面跳转到随机的网址。

js代码|每次随机进入不同网页



2.每次进入网站,自动跳转不同网页

    <script language="javascript">

    var arr = new Array(
        "http://www.zshao.vip/post/2486.html",
        "http://www.zshao.vip/post/2478.html",
        "http://www.zshao.vip/post/638.html",
    );
window.location.href = arr[Math.floor(Math.random() * arr.length)];

</script>


<script>
function changeurl(){
var arr = new Array(
 "http://www.zshao.vip/post/2486.html",
        "http://www.zshao.vip/post/2478.html",
        "http://www.zshao.vip/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>


上一篇:百度蜘蛛IP展示(百度蜘蛛ip展示怎么设置)

下一篇:js代码|特定省份或市区跳转到指定页面(js选择省份和城市代码)

网友评论