Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/04/2005, 20:36
Avatar de aRojilla
aRojilla
 
Fecha de Ingreso: julio-2004
Mensajes: 45
Antigüedad: 20 años, 8 meses
Puntos: 0
Ayuda con selector de hojas de estilo

Hola!!!

Tengo un código que al hacver clicks en varios enlaces puedo cambiar la hoja de estilo del sitio, y funciona muy bien, el caso es que tengo un problema con un iframe... ¿cómo hago para que aplique los cambios en el iframe? Me explico: quiero que cuando se le dé a un link cambie la hoja de estilo del iframe...

Este es el código, un poco largo:

Código PHP:
function setActiveStyleSheet(title) {
var 
iamain;
for(
i=0; (document.getElementsByTagName("link")[i]); i++) {
if(
a.getAttribute("rel").indexOf("style") != -&& a.getAttribute("title")) {
a.disabled true;
if(
a.getAttribute("title") == titlea.disabled false;
}
}
}

function 
getActiveStyleSheet() {
var 
ia;
for(
i=0; (document.getElementsByTagName("link")[i]); i++) {
if(
a.getAttribute("rel").indexOf("style") != -&& a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return 
null;
}

function 
getPreferredStyleSheet() {
var 
ia;
for(
i=0; (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;ca.length;i++) {
var 
ca[i];
while (
c.charAt(0)==' '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"title365);
}

var 
cookie readCookie("style");
var 
title cookie cookie getPreferredStyleSheet();
setActiveStyleSheet(title); 
Luego en el HEAD de las páginas pongo esto:

Código PHP:
<link rel="stylesheet" href="style.css" type="text/css" title="style">
<
link rel="alternate stylesheet" href="style01.css" type="text/css" title="style01">
<
link rel="alternate stylesheet" href="style02.css" type="text/css" title="style02"
Y luego hago los enlaces así:

Código PHP:
<a href="#" onclick="setActiveStyleSheet('style01');">Estilo 1</a
Al pulsar esto la página pasa de la hoja de estilo por defecto a style01.css y si quiero cambiar a style02.css sólo tengo que poner esto:

Código PHP:
<a href="#" onclick="setActiveStyleSheet('style02');">Estilo 2</a
Funciona muy bien, pero...

¿¿¿ cómo hago para que cambie el estilo de la página que tengo en un iframe ???

GRACIAS!!!