Home > Web Front-end > Front-end Q&A > How to disable drag and drop in html

How to disable drag and drop in html

藏色散人
Release: 2023-01-06 11:15:22
Original
5936 people have browsed it

htmlHow to disable drag and drop: first open the corresponding HTML code file; then use the "οndragstart="return false;"" method to disable mouse dragging.

How to disable drag and drop in html

The operating environment of this article: Windows7 system, HTML5 version, DELL G3 computer

Html disable drag and drop function

How to disable it Drag page elements out?

οndragstart="return false;"//禁止鼠标拖动,如拖动图片、连接等
Copy after login

For example:

<body οndragstart="return false;" οncοntextmenu="return false;">
Copy after login

How to disable dragging elements into the page?

<script>
document.ondrop = function(event) {
return false;
};
document.ondragenter  = function(event) {
return false;
};
document.ondragover  = function(event) {
return false;
};
</script>
Copy after login

Recommended learning: "HTML Video Tutorial"

The above is the detailed content of How to disable drag and drop in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template