JavaScript/jQuery如何跳转到指定页面

JavaScript方法:

// 类似于系统自动跳转
window.location.replace("https://www.dustit.me");

// 类似于用户点击操作
window.location.href = "https://www.dustit.me";

模仿用户点击操作时请用 window.location.href 方法。

jQuery 方法:

// jQuery 跳转到指定页面
$(location).attr('href','https://www.dustit.me')
$(window).attr('location','https://www.dustit.me')
$(location).prop('href', 'https://www.dustit.me')

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据