Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make images not selectable

I am making a website in dreamweaver CS5. I exported the images from photoshop an inserted them into a table. When I view the site all the images are selectable(you are able to drag them to your desktop). How do I change this??? I want to do it with an onclick method in addition how would I achieve this?

<td><img src="images/people_03.png" name="one" width="1000" height="156" id="one" ONCLICK="closeimages();"/></td>
like image 812
BDGapps Avatar asked May 12 '11 19:05

BDGapps


People also ask

How do I make a picture not clickable?

Complete HTML/CSS Course 2022 The user select property can be used to prevent this. By setting this property to none, we can prevent our image from being selected (highlighted).

How do I make a picture Unclickable in Word?

Under Display Settings set Link to “None”. Now, when hovering over the image, users will not see the hand that indicates the image can be clicked as a regular link. Best, Christopher M.

How do you make an image draggable in CSS?

To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page. Our example creates an interface to rearrange columns that have been laid out with CSS Grid.

How do you make draggable fake?

Setting the draggable HTML Attribute to false We can also set the draggable HTML attribute of the img element we want to disable dragging for to false . to disable dragging. img. setAttribute("draggable", false);


1 Answers

I stumbled upon this question while struggling with the same problem but the accepted answer was not a possible solution for me.

I used the info found here , in particular adding the following styles to my body, inside the css (this worked for me in Firefox, Chrome and Opera, I cannot test for IE)

-moz-user-select: none;
-webkit-user-select: none;
user-select: none;

The unselectable html tag seems also helpful, but it's apparently supported only by IE and Opera:

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

as well as the javascript solution, that is said to work on IE and webkit browsers:

<script>
window.onload = function() {
    document.body.onselectstart = function() {
        return false;
    }
}
</script>

Note. As Albert Renshaw pointed in the comment this method no longer works in Chrome > 50.

like image 105
BBog Avatar answered Sep 21 '22 07:09

BBog