Javascript拖动选择拖动区域周围的文本和元素

Javascript拖动选择拖动区域周围的文本和元素,javascript,drag-and-drop,resize,prototypejs,Javascript,Drag And Drop,Resize,Prototypejs,我使用以下代码允许用户垂直调整DIV元素的大小,但是当单击并拖动句柄时,页面上的文本和其他元素会被选中,就好像用户只是单击并高亮显示页面上的所有内容一样。有没有办法防止这种情况发生,因为这看起来很糟糕?这将与Prototype.js一起使用 function DragCorner(container, handle) { var container = $(container); var handle = $(handle); // Add property to co

我使用以下代码允许用户垂直调整DIV元素的大小,但是当单击并拖动句柄时,页面上的文本和其他元素会被选中,就好像用户只是单击并高亮显示页面上的所有内容一样。有没有办法防止这种情况发生,因为这看起来很糟糕?这将与Prototype.js一起使用

function DragCorner(container, handle) {
    var container = $(container);
    var handle = $(handle);

    // Add property to container to store position variables
    container.moveposition = {y:0};

    function moveListener(event) {
        // Calculate how far the mouse moved
        var moved = { y:(container.moveposition.y - event.pointerY()) };
        // Reset container's x/y utility property 
        container.moveposition = {y:event.pointerY()};
        // Update container's size
        var size = container.getDimensions();
        container.setStyle({height: size.height + moved.y + 'px'});
    }

    // Listen for 'mouse down' on handle to start the move listener
    handle.observe('mousedown', function(event) {
        // Set starting x/y 
        container.moveposition = {y:event.pointerY()};
        // Start listening for mouse move on body 
        Event.observe(document.body,'mousemove',moveListener);
    });

    // Listen for 'mouse up' to cancel 'move' listener 
    Event.observe(document.body,'mouseup', function(event) {
        Event.stopObserving(document.body,'mousemove',moveListener);
        console.log('stop listening');
    });
}

在前面的问题和答案之后,添加一个小句柄元素,并将其作为唯一可以选择和拖动的元素。另外,我猜您将该div的位置设置为
相对
,并将其处理为
绝对
。右???

将以下内容添加到DIV中修复了此问题:

onselectstart="return false;"

div是固定的,我有一个手柄div,它是一个连接到我正在拉伸的div顶部的div。