I have this code so when a user clicks a div they get taken to another page, just like the <a> tag.

However I want it to open in a new page like target="_blank" but I dont know how.

this is my code so far. Please help

<div onclick="location.href='http://linky.com';" style="background-image: url('http://i39.tinypic.com/11ihg6h.png'); background-repeat:no-repeat; overflow: hidden; padding-left: 75px; padding-top: 8px; width: 75px; height: 50px; font-family: Arial, Helvetica, sans-serif; font-size: 24.41px; font-weight: bold; cursor:pointer; color: black;">1</div>

Recommended Answers

All 2 Replies

Yo can do it this way:

<div onclick="window.open('http://linky.com',target='_blank','width=800,height=600')">1</div>

Thanks

But the target bit doesn't work and isnt needed anyway.

So this would work

<div onclick="window.open('http://linky.com')">1</div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.