chrome sets cursor to text while dragging, why?

前端 未结 8 1234
灰色年华
灰色年华 2020-11-28 09:10

My application has many drag and drop features. While dragging I want the cursor to change to some grab cursor. Internet Explorer and Firefox work fine for this, but Chrome

8条回答
  •  难免孤独
    2020-11-28 09:47

    Try turning off text selection event.

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

    This will disable any text selection on the page and it seems that browser starts to show custom cursors.

    But remember that text selection will not work at all, so it's the best to do it only while dragging, and turn it on again just after that. Just attach function that doesn't return false:

    document.onselectstart = function(){ return true; }
    

提交回复
热议问题