![](/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.