Vincent Tang
Vincent Tang

Reputation: 4170

Disable clickable image but enable right click context menu

enter image description here

Example image from reddit.com

Picture sums up what I want to do with CSS (and JS if needed)

Essentially:

How would I do this purely with CSS (am using chrome stylish plugin) and if needed Javascript?

Currently I was using this:

pointer-events: none; on the CSS class

but this disables the ability to have a right-click context menu

Upvotes: 0

Views: 1830

Answers (2)

JWC May
JWC May

Reputation: 654

Use this: <IMG border=0 src="..." oncontextmenu="return false;">

Demo here: http://www.javascripter.net/faq/rightbu2.htm

Upvotes: 1

Junaid
Junaid

Reputation: 1300

I am not sure if you could do this with CSS only. To accomplish this with JS, try the following code:

<a href="#link" onclick="event.preventDefault();">
    <img src="img.jpg"/>
</a>

Upvotes: 2

Related Questions