Disable Chrome's default click and hold/drag image behavior

Upon using Google Chrome, I have observed a functionality where one can click and hold an image, causing a semi-transparent copy of the image to attach itself to the cursor. This allows the user to drag the image to the desktop for saving purposes.

I am seeking a way to disable this feature and prevent the semi-transparent version of images from attaching to the cursor when held on certain images within my website.

Any suggestions on how I can achieve this?

Answer №1

To avoid this behavior, simply utilize the property:

-webkit-user-drag: auto | element | none;

For more information on -webkit-user-drag, refer to the documentation at CSS-infos.net (I couldn't locate a reference on MDN)


Implementation Instructions

Assign the class .nonDraggableImage to your img elements and include the following CSS:

.nonDraggableImage{
    -webkit-user-drag: none;
}

Answer №2

I had to find an alternative method to make it function properly:

<img src="http://placehold.it/150x150" draggable="false">

Credit:

Answer №3

One method involves placing a transparent image layer on top of the image you wish to safeguard against viewing.

To learn more, visit:

Refer to the section titled "Tricking the downloaders".

Answer №4

I enjoy utilizing the draggable feature.

draggable="true"

<img draggable="true" src="image.jpg">

However, another option to consider is using ondragstart.

ondragstart="return true;"

<img ondragstart="return true;" src="image.jpg">

You could also explore the use of pointer-events (although some browsers may not support it and could have other issues).

style="pointer-events: auto;"

<img src="image.jpg" style="pointer-events: auto;">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a Bootstrap modal that includes a checkbox option to prevent it from appearing again in

I am attempting to display a bootstrap modal upon body load based on a value retrieved from a MySQL database. The bootstrap modal is included in the body and shown successfully depending on the database value using the following code snippet: $results ...

Step by step guide on including a JavaScript function in a web worker using importScripts

I am encountering an issue with my worker.js file: self.importScripts('/static/utils/utils.js') onmessage = (e) => { let a = e.data[0] let b = e.data[1] let c = func1(a,b) postMessage(c) } The structure of the utils.js file ...

I am looking to convert the HTML code into Selenium code

Changing HTML Content <form id="commentUpdateForm" method="post" data-commentid=""> <fieldset> <input type="hidden" name="points" value=""> <di ...

The speed of the jQuery mouse scroll script remains constant and cannot be altered

I've been searching online... I attempted to adjust the scrolling settings on my website but nothing seems to be working. Does anyone have a guide or list of mouse scroll jQuery scripts and functions? (I've cleared caches, performed cross-brow ...

Tips on validating file types using jQuery's Ajax function

I am new to web programming and need help validating and uploading a file. I want to have 2 conditions: if the file type doesn't match, show an alert saying "Invalid file"; second condition, if the file is empty or matches, insert data. However, if th ...

How to disable scrolling for React components with CSS styling

When incorporating a React component into my HTML, I follow this pattern: <html> <body> <div id=app>${appHtml}</div> <script src="/bundle.js"></script> </body> </html> Within my application, th ...

Achieving a stacked arrangement of divs upon click-through using only pure JavaScript

http://jsfiddle.net/Zgxv9/ In the example provided in my fiddle, the div elements return to their original positions when clicked. However, I am looking for a solution where the last clicked div always remains on top. This is my current code: function di ...

Resetting an Angular Material select component

I've encountered an issue with Angular Material. Currently, I have a form with two select elements. The problem arises when I choose a value in one of the selects, it resets and loses its value. Could this be a bug? Or am I possibly making a mistake ...

Creating Dynamic Visibility in ASP.NET Server Controls: Displaying or hiding a textbox based on a dropdown selection

Is there a way to dynamically show/hide a textbox or an entire div section based on a user's selection from a dropdown menu? Can this be achieved using client-side HTML controls instead of server controls? Would utilizing jQuery provide the best solut ...

Is it possible to nest CSS Variables within CSS Variable names?

Is it feasible to embed a CSS Variable inside another CSS variable's name or perform a similar action like this: :root { --color-1: red; --index: 1; } span { color: var(--color-var(--index)) } ...

"Using an empty array before each statement in jQuery Ajax to handle JSON data

I have a script using jQuery that gathers data from multiple websites and then saves it into a SQL database through AJAX and PHP. Right now, the script saves each set of collected data from a site individually. I would like to modify this so that the scrip ...

Setting a simulated GeoLocation in Chrome using Selenium: A step-by-step guide

Is there a way to spoof a GeoLocation in Chrome for Selenium testing? I've attempted using locationcontext and Javascript, but it's not working as intended. I referenced this solution here - fake Geolocation in chrome automation, but it still di ...

What causes the z-index value to stay the same even after it has been modified using the .css() function?

The z-index property defaults to auto, as explained in the MDN documentation. Despite setting the z-index to 1 using the following code: $("body").css("z-index", 1); Upon retrieving the value of z-index with this code: $("body").css("z-index"); The re ...

Is it possible to replicate the functionality of "npm run x" without including a "scripts" entry?

If you want to run a node command within the "context" of your installed node_modules, one way to do it is by adding an entry in the scripts field of your package.json. For example: ... "scripts": { "test": "mocha --recursive test/**/*.js --compiler ...

Is it feasible to exclusively apply Twitter Bootstraps .navbar-fix-to-top on mobile devices?

I am working on a website using Twitter Bootstrap 3 and I have implemented the following navbar: <div class="col-xs-12 col-md-10 col-md-offset-1"> <nav class="navbar navbar-inverse" role="navigation"> <div class="navbar-header"> ...

Limiting the Size of Highcharts Maps with maxWidth or maxHeight

My attempt to adjust the maxWidth of my world map using highcharts isn't altering its size. I have experimented with the following: responsive: { rules: [{ condition: { maxWidth: 500 }, ... As recomme ...

The page you are looking for cannot be located using Jquery AJAX JSON PHP POST -

Whenever I attempt to POST some JSON data to a local host, I consistently encounter a 404 Not Found error. Strangely enough, the php file is positioned precisely where it should be according to the script instructions. If anyone has dealt with this issue b ...

Enhancing Controller Variables with jQuery: A step-by-step guide

I have a date picker widget on my website and I am trying to figure out how to pass the selected date to the controller. In my view, I have the following script snippet: <div id="datepicker"></div> <script type="text/javascript"&g ...

Nextjs optimizing page caching to reduce unnecessary rendering

Within my Next.js application, I have implemented two unique pages. Each page is designed to display a randomly selected person's name when the component is initially loaded. simpsons.tsx export default function Simpsons() { const [person, setPerso ...

Turn off automatic resizing of iframes

I'm currently dealing with a webpage that contains an iframe. The iframe contains quite a bit of data, and every time it loads, its height adjusts to match the content within. Unfortunately, this is causing my page layout to be disrupted. Is there a w ...