JS点击按钮跳转到新的页面 – MasterH's Grocery Store

JS点击按钮跳转到新的页面

首先创建一个a标签,然后设置其target属性为__blankhref属性为链接地址,最后触发click事件。示例代码如下:

const a = document.createElement('a');
a.target = '__blank';
a.href = res.url;
a.click();

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *