基于事件的鼠标光标变化 [英] mouse cursor change based on event

查看:148
本文介绍了基于事件的鼠标光标变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我发送一个Ajax请求。当请求开始,我有

I have an ajax request that I'm sending. When the request starts, I have

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

这立即改变光标的一个旋转圆形的外观。

which immediately changes the appearance of the cursor to a spinning circle.

在请求结束时,我有

  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.

任何想法?

推荐答案

只是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". You can see the difference on any element with text.

这篇关于基于事件的鼠标光标变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆