Latox Latox - 5 months ago 18
HTML Question

Open button in new window?

How would I go about making the button open in a new window, emulating "a href, target = _blank"?

I currently have:

<button class="button" onClick="window.location.href='http://www.site.com';"><span class="icon">Open</span></button>


The button isn't in a form, I just want to make it open in a new window.

Answer

Opens a new window with the url you supplied :)

<button class="button" onClick="window.open('http://www.site.com');"><span class="icon">Open</span></button>

hope that helps :)