Axel Köhler
Axel Köhler

Reputation: 1005

image click but don't select

I want to show an image gallary and to do that, I just have to inport a js script and I have to link to a specific js-link. That's not the problem, it works fine, but when I click the image I linked to the js, it gets selected, like I tried to copy it as I would do with text. How do I prevent that?


EDIT: Just saw that it just selects the image in Dreamweaver, so it works fine in my browser, but if someone does have the problem, feel free to read the answers below.

Upvotes: 0

Views: 401

Answers (2)

bobek
bobek

Reputation: 8020

You can do it with CSS:

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: moz-none;
-ms-user-select: none;
user-select: none;

From here: How to disable text selection highlighting using CSS?

Upvotes: 1

Banning
Banning

Reputation: 2287

This maybe what you're looking for I think... http://www.htmlforums.com/showpost.php?s=036e4d900055ebc4446548d66536e4f1&p=785058&postcount=2

<style>
img{
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}
</style>

you can also use the "unselectable" attribute however not all browsers support it.

<img src="img.jpg" unselectable="on">

Upvotes: 0

Related Questions