为页面设置不同的皮肤就会有不同的.css文件,可以用js实现几种样式间的切换
首先 页面要包含样式文件的引用,跟平时一样只是多一些标识
如:
<link href="../css/General1.css" rel="stylesheet" type="text/css" title="LearningNew1" />
<link href="../css/General2.css" rel="stylesheet" type="text/css" title="LearningNew2" />
<link href="../css/General2.css" rel="stylesheet" type="text/css" title="LearningNew3" />
<link href="<%=ResolveUrl("~/css") %>/ableico.css" rel="stylesheet" type="text/css" />
<script src="StudyPlanList.js" type="text/javascript"></script>
在StudyPlanList.js 中写如下代码
$(document).ready(function() {
setActiveStyleSheet("LearningNew2") ;//切换要显示的样式
});
function setActiveStyleSheet(title) {
var i, a, main;
for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
if (a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("title")) {
a.disabled = true;
if (a.getAttribute("title") == title) a.disabled = false;
}
}
}
















