简体   繁体   中英

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". 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).

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.

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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