Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a whole div clickable in order to launch a _blank document

Tags:

javascript

How can I write the _blank statement in this location.href call?

  <div onclick="location.href='http://www.test.com';" style="display:block; height:40px; width:100px; cursor:pointer;"></div> 

Please note: I need to keep the div and treat it as a href container.
When someone clicks it should open a new browser window, not a popup box.

like image 681
detonate Avatar asked Dec 02 '22 04:12

detonate


1 Answers

<div onclick="window.open('http://www.test.com','new_window');" style="display:block; height:40px; width:100px; cursor:pointer;">test</div> 
like image 103
Chris Ballance Avatar answered Dec 04 '22 13:12

Chris Ballance