首页 > 代码库 > 按钮实现A标签新窗口打开(不用window.open)

按钮实现A标签新窗口打开(不用window.open)

<button type="button" onclick="goBaidu()">click</button><script>     function goBaidu(){        var a = document.createElement(a);        var e = document.createEvent(MouseEvents);        e.initEvent( click, true, true );        a.href="http://www.baidu.com";        a.target="_blank";        a.dispatchEvent(e);    }</script>

 

按钮实现A标签新窗口打开(不用window.open)