Home > Article > Web Front-end > How to disable drag and drop in html
htmlHow to disable drag and drop: first open the corresponding HTML code file; then use the "οndragstart="return false;"" method to disable mouse dragging.
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;"//禁止鼠标拖动,如拖动图片、连接等
For example:
<body οndragstart="return false;" οncοntextmenu="return false;">
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>
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!