1、cookies:
var theme = $.cookies.get("theme_platform") || "Blue";
changeTheme(theme, false);
function changeTheme(themeName, isCng)
{
if (!themeName || themeName.toString().trim().length == 0)
{
themeName = $.cookies.get("theme_platform")
}
$("span[class^='mainTheme_']").each(function ()
{
var cssName = $(this).attr("class");
$(this).removeClass().addClass(cssName.replace("1", ""));
});
try
{
themeName=themeName.toLowerCase();
var current=$(".mainTheme_" + themeName)||$(".mainTheme_" + themeName+"1");
current.removeClass().addClass("mainTheme_" + themeName + "1");
}
catch(e){}
if(isCng)
{
RoadUI.Core.allFrames = [];
RoadUI.Core.getAllFrames();
for (var i = 0; i < RoadUI.Core.allFrames.length; i++)
{
$("#style_style", RoadUI.Core.allFrames[i].document).attr("href", rootdir + "/Themes/" + themeName + "/Style/style.css");
$("#style_ui", RoadUI.Core.allFrames[i].document).attr("href", rootdir + "/Themes/" + themeName + "/Style/ui.css");
}
$.cookies.set("theme_platform", themeName, { expiresAt: new Date(2099, 1, 1) });
}
}
C#后台取值:
public static string Theme
{
get
{
var cookie = System.Web.HttpContext.Current.Request.Cookies["theme_platform"];
return cookie != null && !cookie.Value.IsNullOrEmpty() ? cookie.Value : "Blue";
}
}