Open button in new window?

Latox picture Latox · Jan 10, 2011 · Viewed 160.2k times · Source

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.example.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

Damien-Wright picture Damien-Wright · Jan 10, 2011

Opens a new window with the url you supplied :)

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

hope that helps :)