Question

I have added following code in wordpress to hide status bar. It works but I want to open link in new window. How can I do that?

<img style='cursor:pointer;' src='http://www.killerpreseller.com/images2/buynow.gif' onclick="window.location='http://www.yahoo.com'"/>
Was it helpful?

Solution 2

You can use:

window.open('http://www.killerpreseller.com/images2/buynow.gif', '_blank');

As per How to simulate target="_blank" in JavaScript

This is the equivalent of an anchor tag with target='blank' set.

OTHER TIPS

Use an anchor with target '_blank' wrapping your image

<a href='http://www.killerpreseller.com/images2/buynow.gif' target='_blank'>
   <img style='cursor:pointer;' src='http://www.killerpreseller.com/images2/buynow.gif' />
</a>

http://jsfiddle.net/Ree5t/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top