繁体   English   中英

浏览器之间的鼠标事件游标差异

[英]Mouse event cursor difference between browsers

我使用鼠标悬停来获取光标类型,我在Chrome和Firefox中获得不同的结果当鼠标因某些原因结束时,Chrome中的光标样式为“auto”,而Firefox中的光标样式为“text”。 我需要知道光标在两个浏览器中是默认的,何时是自动的(因为它假设是通过文本输入)或文本。

我在这里写了一个简单的代码来重现这个问题,在Chrome和Firefox上尝试它并看到差异(如果你想使用代码,这里是jsfiddle )。

提前致谢 :)

 window.onmouseover=function(event) { var currentCursor = $(event.target).css('cursor'); console.log(currentCursor); $('#pointer').html(currentCursor); }; 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <input type="text" width="100"> <p>Move the mouse in and out the input field</p> <p id='pointer'></p> 

Chrome和Firefox可能会为输入控件使用不同的默认工作表。

如果您想确定可以设置自己的样式表并强制将光标强制为文本类型输入的“文本”。

 window.onmouseover=function(event) { var currentCursor = $(event.target).css('cursor'); console.log(currentCursor); $('#pointer').html(currentCursor); }; 
 input[type="text"] { cursor:text } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <input type="text" width="100"> <p>Move the mouse in and out the input field</p> <p id='pointer'></p> 

暂无
暂无

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

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