开发者

Javascript: How can I set the cursor during a drag & drop operation on a website?

开发者 https://www.devze.com 2023-03-07 16:11 出处:网络
I am developing a Chrome browser extension that allows a drag & drop kind of operation everywhere on the page. However, while the user performs this operation the cursor is usually changed to the

I am developing a Chrome browser extension that allows a drag & drop kind of operation everywhere on the page. However, while the user performs this operation the cursor is usually changed to the text cursor.

How can I alter that behaviour? The CSS cursor property seems to only kick in when you're not holding the mouse button 开发者_如何学编程down.

PS: Since, I'm developing an extension for Google Chrome, other browser do not matter to me.


Simply override the "dragstart" message handler as well as the "selectstart"... While in the function cancel the event...

<script type="text/ecmascript">
window.addEventListener("dragstart", function(fEventObject){ CancelEvent(fEventObject); } );
window.addEventListener("selectstart", function(fEventObject){ CancelEvent(fEventObject); } );

function CancelEvent(fEventObject) 
{
   if (fEventObject.preventDefault) fEventObject.preventDefault();
   if (fEventObject.cancel != null) fEventObject.cancel = true;
}

</script>


Could you add a css class to the body tag, that sets the cursor, then remove than class on drop?

0

精彩评论

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