是否有人知道如何更改JavaScript的SharePoint 2010客户对象模型显示的通知弹出窗口的颜色?以下总是给我一个绿色的弹出窗口:

SP.UI.Notify.addNotification('Operation Complete', true);

我很确定有可能获得其他颜色,因为我在各种博客上都看到了它们。我只是不确定该怎么做。

有帮助吗?

解决方案

与sp.ui.Status不同,您没有直接的通知设置颜色的方法,但是由于它是一个简单的HTML字符串,您正在添加 确定进入通知区域的原因。

我没有对其进行测试,但是以下语法应该是合法的:

SP.UI.Notify.addNotification('<span style=\'background-color:red\'>Operation Complete</span>', true);

编辑:我调试了通知类,并根据天气工具提示和OnClickHandler设置了跨度跨度(查看core.debug.js中的_addnotificationInternal方法)。所使用的类是S4-Noti,S4-Noti-Noti,S4-Noti-In1 to -in3 to -in3 ask ascev4.css(_layouts styles themable temable temable corev4.css)。在这里,您还将看到许多颜色实际上是由所选主题控制的。

我使用CSS规则来编辑他们的运行时间:

function notifyMe()
{
    var sheet = document.styleSheets[6];
    var rules = sheet.cssRules ? sheet.cssRyles : sheet.rules; //cross browser rules
    for (i=0;i<rules.length;i++)
    {
        if (rules[i].selectorText.toLowerCase()==".s4-noti")
           rules[i].style.backgroundColor = 'red';
        if (rules[i].selectorText.toLowerCase()==".s4-noti-noti")
           rules[i].style.backgroundColor = 'green';
        if (rules[i].selectorText.toLowerCase()==".s4-noti-in1")
           rules[i].style.backgroundColor = 'blue';
        if (rules[i].selectorText.toLowerCase()==".s4-noti-in2")
           rules[i].style.backgroundColor = 'purple';
        if (rules[i].selectorText.toLowerCase()==".s4-noti-in3")
           rules[i].style.backgroundColor = 'magenta';
    }
    var nid = SP.UI.Notify.addNotification("test", true); 
}

这并没有完全造成它们的样式,但应该让您了解如何根据需要编辑它们。

其他提示

要了解颜色如何变化以及有关SharePoint Notification状态栏的更多信息,请阅读本文。 http://www.anmolrehan-sharepointconsultant.com/2011/06/sharepoint-status-bar-and-notification.html

许可以下: CC-BY-SA归因
scroll top