【问题标题】:changing the cursor of mouse by jsjs改变鼠标光标
【发布时间】:2011-01-11 19:35:18
【问题描述】:

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

【问题讨论】:

  • 您可以发布您的任何代码吗?从您包含的单行来看,语法似乎是正确的。
  • 有点像:function BaforeCallingAjaxMethod(){document.body.style.cursor="wait"; CallAjaxMethodNow();}

标签: javascript dynamics-crm dynamics-crm-4


【解决方案1】:

你正在做的工作。

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

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

还注意到我将正文的widthheight 拉伸到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';

【讨论】:

  • 不,它是 ms crm dynamics 4.0 上的自定义实体,目前我无法为其注入 css,另一个想法?
  • @Danny:您可以选择通过 javascript 注入样式表吗?
  • @Danny:Give this a try.我会在一分钟内用内容更新我的答案。
猜你喜欢
  • 2012-08-22
  • 1970-01-01
  • 2015-09-27
  • 1970-01-01
  • 2010-11-16
  • 2017-12-02
  • 1970-01-01
  • 1970-01-01
  • 2018-06-10
相关资源
最近更新 更多