![](/img/trans.png)
[英]JavaScript function only for one div, and not whole document
[英]How to change cursor for the whole document (not only within the body) via JavaScript?
以跨瀏覽器的方式,僅使用JavaScript。
我認為您遇到的問題是body
元素沒有填充視口,因為頁面上沒有太多內容(在IE上尤其如此)。 您可以強制它使用CSS填充視口:
html, body {
height: 100%;
cursor: pointer;
}
...然后確保光標是視口中任何地方的指針。
編輯 :並且確保確保body
元素填充了視口,您可以在document.body
上使用style
對象從JavaScript設置光標。 因此,將其更改為十字准線:
document.body.style.cursor = 'crosshair';
如果您根本無法預先應用CSS,那么這似乎可行:
document.documentElement.style.height = "100%";
document.body.style.height = "100%";
document.body.style.cursor = "pointer";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.