簡體   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