简体   繁体   English

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

[英]Mouse event cursor difference between browsers

I use mouseover to get the cursor type, i get different results in Chrome and in Firefox when mouse is over for some reason the cursor style in Chrome is "auto" and in Firefox is "text". 我使用鼠标悬停来获取光标类型,我在Chrome和Firefox中获得不同的结果当鼠标因某些原因结束时,Chrome中的光标样式为“auto”,而Firefox中的光标样式为“text”。 I need to know when the cursor is default in both browsers and when it's auto (as it's suppose to be over text input) or text. 我需要知道光标在两个浏览器中是默认的,何时是自动的(因为它假设是通过文本输入)或文本。 .

I wrote a simple code here to reproduce the issue, try it on both Chrome and Firefox and see the difference (here it is at jsfiddle if you want to play with the code). 我在这里写了一个简单的代码来重现这个问题,在Chrome和Firefox上尝试它并看到差异(如果你想使用代码,这里是jsfiddle )。

Thanks in advance :) 提前致谢 :)

 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 and Firefox probably use a different default sheet for the input controls. Chrome和Firefox可能会为输入控件使用不同的默认工作表。

If you want to be sure you can set your own stylesheet and force the cursor to be 'text' of inputs of type text. 如果您想确定可以设置自己的样式表并强制将光标强制为文本类型输入的“文本”。

 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