[英]changing the cursor of mouse by js
i trying to change the cursor of mouse by using js for MS CRM dynamics 4.0, when i calling to method by using ajax, i want to display the cursor of mouse as wait: document.body.style.cursor="wait"; 我试图通过使用js来更改鼠标指针,以用于MS CRM Dynamics 4.0,当我使用ajax调用方法时,我希望将鼠标指针显示为wait:document.body.style.cursor =“ wait”; but it's not working... how can i doing it? 但它不起作用...我该怎么办?
What you're doing works. 您正在做什么。
Keep in mind that if the cursor
is set in CSS on any descendants, that will override the cursor setting on body
. 请记住,如果cursor
在CSS设置任何后代,这将覆盖光标设置body
。
Example: http://jsfiddle.net/88272/ 示例: http : //jsfiddle.net/88272/
Also notice that I stretched the width
and height
of the body to 100%
. 另请注意,我将身体的width
和height
拉伸到100%
。
Here's a possible solution if other elements are overwriting. 如果其他元素被覆盖,这是一个可能的解决方案。
Add this to your css: 将此添加到您的CSS:
body.isWaiting, body.isWaiting * {
cursor:wait !important;
}
...then do: ...然后做:
document.body.className = 'isWaiting';
Example: http://jsfiddle.net/88272/3/ 示例: http : //jsfiddle.net/88272/3/
You'll need to test for browser compatibility. 您需要测试浏览器的兼容性。
EDIT: 编辑:
Since it sounds as though you can't add your own style sheet on the server side, you could instead try to add one via javascript. 由于听起来好像您无法在服务器端添加自己的样式表,因此您可以尝试通过javascript添加样式表。
Example: http://jsfiddle.net/88272/4/ 示例: http : //jsfiddle.net/88272/4/
// string representation of stylesheet content
var styles = 'body.isWaiting, body.isWaiting * {cursor:wait !important;}';
// grab the <head> element
var head = document.getElementsByTagName('head')[0];
// create a new "style" element, and set up its properties/content
var sheet = document.createElement('style');
sheet.setAttribute('media', 'all');
sheet.setAttribute('type', 'text/css');
if(sheet.styleSheet) {
sheet.styleSheet.cssText = styles; // For IE
} else {
sheet.appendChild( document.createTextNode(styles) );
}
// append the new <style> element to the <head>
head.appendChild( sheet );
// give the <body> the class when it is needed
document.body.className = 'isWaiting';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.