使用click去替代href

实现广告点击,Insus.NET想使用click来替代href。

为什么要这样子做,因为一些广告的链接为站外链接,但需要在系统中做一些事情之后才让其转跳。

以上是在Vue环境中使用。

 

 

转跳代码:

 const a = document.createElement('a');
                            a.style.display = 'none';
                            a.href = url;
                            a.target = "_blank";
                            a.click();
                            document.body.removeChild(a);
Source Code

 

posted @ 2020-09-29 07:42  Insus.NET  阅读(307)  评论(0编辑  收藏  举报