Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 621
Ram Segev Avatar asked Oct 30 '22 21:10

Ram Segev


1 Answers

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>
like image 124
alebianco Avatar answered Nov 12 '22 17:11

alebianco