How can I disable Text Selection temporarily using JavaScript?

只愿长相守 提交于 2019-11-28 10:50:49

In W3C browsers, you can call the preventDefault method on the event object. The IE equivalent is to set the returnValue to false.

function stopDefault(e) {
    if (e && e.preventDefault) {
        e.preventDefault();
    }
    else {
        window.event.returnValue = false;
    }
    return false;
}

EDIT: Just re-read the question and you might also want to prevent the default action in the part of your code that handles the actual dragging, and not just at the initial mousedown or click.

as far I know, dragged element must be positioned over other elements under mouse pointer. If it will moving with the mouse pointer, it prevent any selections on the page.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!