How can I write the _blank statement in this location.href call?
<div onclick="location.href='';" 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.
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.
- 1 Howcome you're using a <div> instead of an <a> tag? – Ian Oxley Commented Dec 20, 2010 at 16:57
- I need to keep the div and treat it as a href block. When someone clicks it should open a new browser window, not a popup box. – detonate Commented Dec 20, 2010 at 17:08
4 Answers
Reset to default 13<div onclick="window.open('http://www.test.com','new_window');" style="display:block; height:40px; width:100px; cursor:pointer;">test</div>
Use window.open.
or using jquery:
$(this).click(function(){
$(this).open(
{
width: 400,
height: 250,
scrollbars: false
});
});
use an <a>
instead of a <div>
<a href="http://www.example.com" target="_blank" style="display:block; width:100px; height:40px;">CONTENT</a>