html - 在鼠标移动之前鼠标光标不可见(在 Chrome 中)
问题描述
我有一个 HTML 页面,其中鼠标光标设置为none
. 在某些情况下,我将其设置为crosshair
. 不幸的是,在用户实际移动鼠标之前,不会显示光标。如果鼠标没有移动,光标将保持不可见。
如何告诉浏览器在不移动鼠标的情况下重绘光标?
编辑:可能的重复不是重复的。显然这个问题在 Firefox 和 Internet Explorer 中得到了解决,但在 Chrome 中没有得到解决。
解决方案
先看看这个答案,它可能就是你要找的。如果没有,我会尝试手动触发事件。我不确定这会起作用,因为即使在触发事件之后,它也不能保证浏览器会重绘鼠标光标:
// listen to mouse move event
window.onmousemove = function(e) {
console.log('mouse moved.', e);
};
// create and trigger the event
var event = new Event('mousemove');
window.dispatchEvent(event);
// should now see 'mouse move.' in the console.
如果这不起作用,您可能需要使用其他鼠标事件进行测试。
推荐阅读
- php - 基本 PHP 函数返回一个空白页
- android - Not being able to switch the toolbar for a different activity [Fixed]
- angular - 如何在角度材料ui中的mat-menu内放置下拉菜单
- python - 如何从这个压缩的 PDF/A 中提取文本?
- python - 如何搜索二维列表并打印位置(x,y)
- java - 如何区分本地wifi网络android游戏中的用户
- raspberry-pi - 通过树莓派 4 访问气流网络
- python - Gmail API 无法获取电子邮件数据
- swift - RealityKit 多人会话 - 对象同步问题
- spring-security - JWT 于 2020-05-13T07:50:39Z 到期。当前时间:2020-05-16T21:29:41Z。正如日志错误所说,我的 jwt 到期后出现此错误