javascript - 通过js改变鼠标光标

标签 javascript dynamics-crm dynamics-crm-4

我尝试使用MS CRM Dynamics 4.0的js来更改鼠标光标, 当我使用ajax调用方法时,我想将鼠标光标显示为等待: document.body.style.cursor="等待"; 但它不起作用...我该怎么做?

最佳答案

你正在做的事情有效。

请记住,如果在任何后代的 CSS 中设置了 cursor,这将覆盖 body 上的光标设置。

示例: http://jsfiddle.net/88272/

另请注意,我将正文的宽度高度拉伸(stretch)至100%


如果其他元素被覆盖,这是一个可能的解决方案。

将其添加到您的 CSS 中:

body.isWaiting, body.isWaiting * {
    cursor:wait !important;
}

...然后执行:

document.body.className = 'isWaiting';

示例: http://jsfiddle.net/88272/3/

您需要测试浏览器兼容性。


编辑:

由于听起来您无法在服务器端添加自己的样式表,因此您可以尝试通过 JavaScript 添加样式表。

示例: 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';

关于javascript - 通过js改变鼠标光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4661793/

相关文章:

javascript - 如果没有打开页面,Phantom JS 可以运行吗

javascript - 与 useEffect 一起使用时如何防止 useCallback 触发(并遵守 eslint-plugin-react-hooks)?

C# - 仅使用选项的字符串名称设置 CRM OptionSetValue

dynamics-crm - Dynamics CRM 中的 OnChange 和 AddOnChange 之间有什么区别

dynamics-crm-2011 - 检索 N :N Relationship in Dynamics Crm

javascript - D 3's use of the ' 选择'和 'selectAll'

javascript - 代码点火器+ Angular Js : How to use partials?

javascript - 在 Dynamics 365 和 JavaScript 中显示相关实体

c# - 早期绑定(bind)类的使用

dynamics-crm - MS CRM 4 - 具有 "regardingobjectid"功能的自定义实体