开发者

How to disable ondblclick in JavaScript?

开发者 https://www.devze.com 2023-01-28 11:21 出处:网络
Is it possible to disable the ondblclic开发者_如何学运维k event?document.ondblclick = function() { return false; }

Is it possible to disable the ondblclic开发者_如何学运维k event?


document.ondblclick = function() { return false; }

...or if you didn't want to do it site-wide.

document.getElementById('something').ondblclick = function() { return false; }


You can use:

event.preventDefault();
event.stopPropagation(); 
event.stopImmediatePropagation();


<script type="text/javascript">
document.ondblclick = function DoubleClick(evt) {
    if (window.getSelection)
        window.getSelection().removeAllRanges();
    else if (document.selection)
        document.selection.empty();
}
</script>

This code will disable selecting text via double click

0

精彩评论

暂无评论...
验证码 换一张
取 消