欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何使用JavaScript和jQuery实现页面自动跳转?

最编程 2024-08-08 10:48:45
...

JavaScript 和 jQuery 跳转页面的方法有很多种,下面整理了几个:

1、利用 http 重定向进行跳转:

window.location.replace("https://www.w3h5.com");

2、使用 href 进行跳转

window.location.href = "https://www.w3h5.com";

3、使用 jQuery 的属性替换方法

// 方法一
$(location).attr('href', 'https://www.w3h5.com');
// 方法二
$(window).attr('location','https://www.w3h5.com');
// 方法三
$(location).prop('href', 'https://www.w3h5.com')

(adsbygoogle = window.adsbygoogle || []).push({});