当前位置: 代码迷 >> Web前端 >> 静态页面兑现换肤功能(无cookie)
  详细解决方案

静态页面兑现换肤功能(无cookie)

热度:98   发布时间:2012-09-10 11:02:32.0
静态页面实现换肤功能(无cookie)

?

//1、将已存在的样式表css禁用掉

??for ( i = 0; i < document.styleSheets.length; i++ )
???????{
????????document.styleSheets[i].disabled = true;
???????}

?

//2、添加新的样式表

?????? var selectedTheme = ...;//目标样式的路径

?

?????? var head = document.getElementsByTagName('HEAD').item(0);
???????

???????var ga = document.createElement('link');
???????ga.rel = "stylesheet";
???????ga.type = 'text/css';?
???????ga.href = selectedTheme ;
???????head.appendChild(ga);

  相关解决方案