JavaScript打开新页面的两种方式:当前页面打开和新页面跳转

在前台开发中会涉及页面跳转的问题,页面跳转有两种:一种是当前页面打开新的页面,一种是新的标签页跳转到新的页面。

1、跳转到新页面打开页面:

window.open('http://www.baidu.com','_blank');

2、当前页面打开新的地址:

window.open('http://www.baidu.com','_self');

如果在a标签中进行跳转那么就是用到了target:
1、新的标签页打开:

 <a href="http://www.baidu.com" class="class1" target="_blank">

2、当前页面打开

 <a href="http://www.baidu.com" class="class1" target="_self">

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41153943/article/details/104774195