winney

It is never too old to learn.

0%
winney

WEB前端-页面跳转的相关处理

跳转到新页面

1
window.location.assign('https://www.baidu.com/');
1
window.location.href = https://www.baidu.com/

如果想在新标签中打开:

1
window.open("https://www.baidu.com/");

阻止浏览器的默认行为

1
2
3
4
5
function stopDefault(e) { 
if ( e && e.preventDefault ) {
e.preventDefault();
}
}