Make images not selectable

2020-02-28 05:14发布

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>

4条回答
Anthone
2楼-- · 2020-02-28 05:23

I would use pointer-events: none; in my CSS

img {
  pointer-events: none;
}
查看更多
看我几分像从前
3楼-- · 2020-02-28 05:28

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.

查看更多
可以哭但决不认输i
4楼-- · 2020-02-28 05:29

This works:

pointer-events: none;
user-select: none;
查看更多
ら.Afraid
5楼-- · 2020-02-28 05:43

Easiest way I think would be to make the images as css background images to each cell

查看更多
登录 后发表回答