使用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
原文地址:https://www.cnblogs.com/insus/p/13747876.html