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'"/>
Était-ce utile?

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

Autres conseils

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top