Mudar Cor de site
http://forum.imasters.com.br/public/style_emoticons/default/blush.gif Fala ai galera do forum, eu tenho um codigo em js que faz a troca de estilos css assim trocando a cor do site todo e tals, mais eu to com um problema, eu queria saber como que eu faço pra poder trocar as cores das subpáginas atraves de iframe, se exisitir uma solução queria saber como eu to pensando em ajax mais nao sei como as outras páginas vao comporta através disso. um grande obrigado vou deixar o codigo pra terem uma ideia
ps: esse codigo so funciona na pagina principal q ele tem o codigo,mais nas pastas que carregem no centro da página o tema nao se aplica as páginas ficam com o cor do tema principal.
styleswitcher.js
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;
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
inicial.html
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.:: NightMix Rio ::. A sua night é Aqui!</title>
<link rel="stylesheet" type="text/css" href="css/corpo.css" />
<link rel="alternate stylesheet" type="text/css" href="css/tema1.css" title="tema1" />
<link rel="alternate stylesheet" type="text/css" href="css/tema2.css" title="tema2" />
<script type="text/javascript" src="src/styleswitcher.js"></script>
</head>
<body>
<div id="textfundos">Mude o fundo do topo:</div>
<div id="fudnopic1"><a href="javascript:setActiveStyleSheet('tema1');">
<img src="layout/sl1.jpg" width="34" height="29" /></a></div>
<div id="fudnopic2"><a href="javascript:setActiveStyleSheet('tema2');">
<img src="layout/sl2.jpg" width="34" height="29" /></a></div>
</body>
</html>Discussão (2)
Carregando comentários...