JavaScript实现页面跳转的八种方式包括:
- 使用window.location.href实现页面跳转:
window.location.href = "http://www.example.com";
- 使用location.replace实现页面跳转,替换当前页面:
location.replace("http://www.example.com");
- 使用location.assign实现页面跳转,添加到浏览器的历史记录中:
location.assign("http://www.example.com");
- 使用location.reload实现页面刷新:
location.reload();
- 使用window.open实现在新窗口中打开页面:
window.open("http://www.example.com");
- 使用document.location实现页面跳转:
document.location = "http://www.example.com";
- 使用location.href和setTimeout实现延时跳转:
setTimeout(function(){ location.href = "http://www.example.com"; }, 2000);
- 使用location.href和onload事件实现页面加载完成后跳转:
window.onload = function(){ location.href = "http://www.example.com"; };