This is my code:
<a href="http://www.google.com" onClick="window.location.href='http://www.yahoo.com';return false;" target="_blank">test</a>
When you click it, it takes you to Yahoo but it does not open a new window?
This is my code:
<a href="http://www.google.com" onClick="window.location.href='http://www.yahoo.com';return false;" target="_blank">test</a>
When you click it, it takes you to Yahoo but it does not open a new window?
<a href="#" onClick="window.open('http://www.yahoo.com', '_blank')">test</a>
Easy as that.
Or without JS
<a href="http://yahoo.com" target="_blank">test</a>
addEventListener
instead of inlining JS in the HTML. –
Nantucket In order to open a link in a new window, add Javascript command
onclick="window.open('text-link.htm', 'name','width=600,height=400')
inside the <a>
tag:
<a href="../html-link.htm" target="popup" onclick="window.open('../html-link.htm','name','width=600,height=400')">Open page in new window</a>
to open in a window.
<a href="http://www.google.com" onclick="window.open(this.href, 'new', 'popup'); return false;">Open in a window</a>
Given answer might be helpful when you want to open a new tab or browser user preference is set to open new window instead of tab, since the original question is about open new window not a tab, here is what works for me.
<a href="#" onClick='window.open(url, "_blank", "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=600);'>test</a>
© 2022 - 2024 — McMap. All rights reserved.