Javascript 用js改变鼠标光标
我尝试使用js for MS CRM dynamics 4.0更改鼠标光标, 当我使用ajax调用方法时,我想将鼠标光标显示为wait: document.body.style.cursor=“wait”;Javascript 用js改变鼠标光标,javascript,dynamics-crm,dynamics-crm-4,Javascript,Dynamics Crm,Dynamics Crm 4,我尝试使用js for MS CRM dynamics 4.0更改鼠标光标, 当我使用ajax调用方法时,我想将鼠标光标显示为wait: document.body.style.cursor=“wait”; 但它不起作用。。。我该怎么做呢?你做的很有效 请记住,如果在任何子体上的CSS中设置了光标,则将覆盖正文上的光标设置 示例: 还请注意,我将主体的宽度和高度拉伸为100% 如果其他元素被覆盖,这里有一个可能的解决方案 将此添加到css中: body.isWaiting, body.isWa
但它不起作用。。。我该怎么做呢?你做的很有效 请记住,如果在任何子体上的CSS中设置了
光标
,则将覆盖正文
上的光标设置
示例:
还请注意,我将主体的宽度
和高度
拉伸为100%
如果其他元素被覆盖,这里有一个可能的解决方案 将此添加到css中:
body.isWaiting, body.isWaiting * {
cursor:wait !important;
}
…然后做:
document.body.className = 'isWaiting';
示例:
您需要测试浏览器兼容性
编辑: 因为听起来好像您无法在服务器端添加自己的样式表,所以您可以尝试通过javascript添加一个样式表 示例:
//样式表内容的字符串表示
var styles='body.isWaiting,body.isWaiting*{cursor:wait!important;}';
//抓住元素
var head=document.getElementsByTagName('head')[0];
//创建新的“样式”元素,并设置其属性/内容
var sheet=document.createElement('style');
sheet.setAttribute('media','all');
sheet.setAttribute('type','text/css');
if(sheet.styleSheet){
sheet.styleSheet.cssText=styles;//用于IE
}否则{
sheet.appendChild(document.createTextNode(样式));
}
//将新元素附加到
头、子(张);
//在需要的时候给学生上课
document.body.className='isWaiting';
您可以发布您的任何代码吗?从您包含的一行来看,语法似乎是正确的。它类似于:function BaforeCallingAjaxMethod(){document.body.style.cursor=“wait”;CallAjaxMethodNow();}不,它是ms crm dynamics 4.0上的自定义实体,目前我无法为它插入css,另一个想法?@Danny:您可以选择通过javascript注入样式表吗?@Danny:我马上用内容更新我的答案。
// 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';