-1
我使用硒來自動化測試瀏覽器應用程序,我需要一個JavaScript API來獲取瀏覽器當前的光標樣式,而不關心它在哪裏。是否有一些API獲取信息鏈接document.readstate如何使用javascript從瀏覽器中獲取當前光標樣式
我使用硒來自動化測試瀏覽器應用程序,我需要一個JavaScript API來獲取瀏覽器當前的光標樣式,而不關心它在哪裏。是否有一些API獲取信息鏈接document.readstate如何使用javascript從瀏覽器中獲取當前光標樣式
以下腳本檢測並打印頁面上任何元素上的光標樣式瀏覽器。
document.addEventListener('mouseover',function(e){
var cursor = e.target.style.cursor;
console.log(cursor);
},false);
span.crosshair {
cursor: crosshair;
}
span.help {
cursor: help;
}
span.wait {
cursor: wait;
}
<p>Mouse over the words to change the cursor.</p>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:grab">grab</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text">text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>
<span style="cursor:not-allowed">not-allowed</span><br>
<span style="cursor:no-drop">no-drop</span><br>
的可能的複製[檢測遊標類型(http://stackoverflow.com/questions/5304668/detect-cursor-type) –
@RobinDorbell我認爲這個問題是不是真的一個副本,因爲OP詢問(不關心它在哪裏),而不是問題http://stackoverflow.com/questions/5304668/detect-cursor-type專門檢查輸入標記的光標輸入,它使用selectionStart和selectionEnd,爲我的理解OP的問題更爲通用,不限於輸入標籤檢測。 – GibboK