简体   繁体   English

鼠标光标根据事件更改

[英]mouse cursor change based on event

I have an ajax request that I'm sending. 我有一个我要发送的ajax请求。 When the request starts, I have 当请求开始时,我有

  document.body.style.cursor = "wait";

which immediately changes the appearance of the cursor to a spinning circle. 它会立即将光标的外观更改为旋转圆圈。

When the request ends, I have 当请求结束时,我有

  document.body.style.cursor = "default";

However, this only returns the cursor to its original state when the user moves the mouse; 但是,这只会在用户移动鼠标时将光标返回到其原始状态。 if the mouse stays still, the cursor won't change. 如果鼠标保持不动,则光标不会改变。 When you set it to "auto" or any other kind, the cursor change will only trigger when it moves. 当您将其设置为“自动”或任何其他类型时,光标更改将仅在其移动时触发。

Any ideas? 有任何想法吗?

just scroll window by 0,0. 只需滚动窗口0,0。

document.body.style.cursor = "auto";
window.scroll(0, 0);
// tested in IE8 and FF3.6

And when the request ends, you need to set cursor to "auto", not a "default". 当请求结束时,您需要将光标设置为“auto”,而不是“默认”。 You can see the difference on any element with text. 您可以在带有文本的任何元素上看到差异。

这是一个chrome bug: http//code.google.com/p/chromium/issues/detail? id = 26723

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM