这是我的代码:
<a href="http://www.google.com" onClick="window.location.href='http://www.yahoo.com';return false;" target="_blank">test</a>
当您单击它时,它会将您带到雅虎,但不会打开新窗口?
<a href="#" onClick="window.open('http://www.yahoo.com', '_blank')">test</a>
就这么简单。
或者没有JS
<a href="http://yahoo.com" target="_blank">test</a>
为了在新窗口中打开链接,请添加Javascript命令
onclick="window.open('text-link.htm', 'name','width=600,height=400')
在 <a>
标签内:
<a href="../html-link.htm" target="popup" onclick="window.open('../html-link.htm','name','width=600,height=400')">Open page in new window</a>
当您想打开新选项卡或浏览器用户首选项设置为打开新窗口而不是选项卡时,给出的答案可能会有所帮助,因为最初的问题是关于打开新窗口而不是选项卡,这对我有用。
<a href="#" onClick='window.open(url, "_blank", "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=600);'>test</a>
在窗口中打开。
在窗口中打开