Foros del Web » Programando para Internet » Javascript »

Ayuda con selector de hojas de estilo

Estas en el tema de Ayuda con selector de hojas de estilo en el foro de Javascript en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 04/04/2005, 20:36
Avatar de aRojilla  
Fecha de Ingreso: julio-2004
Mensajes: 45
Antigüedad: 19 años, 9 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!!!
  #2 (permalink)  
Antiguo 05/04/2005, 14:19
Avatar de aRojilla  
Fecha de Ingreso: julio-2004
Mensajes: 45
Antigüedad: 19 años, 9 meses
Puntos: 0
mmmm... parece que hago siempre preguntas muy difíciles...

una ayuditaaaaaaa!!!! por favor!!!!

GRACIAS!!!

  #3 (permalink)  
Antiguo 06/04/2005, 13:01
Avatar de aRojilla  
Fecha de Ingreso: julio-2004
Mensajes: 45
Antigüedad: 19 años, 9 meses
Puntos: 0
nadie va a decirme algo???
  #4 (permalink)  
Antiguo 07/04/2005, 16:34
Avatar de aRojilla  
Fecha de Ingreso: julio-2004
Mensajes: 45
Antigüedad: 19 años, 9 meses
Puntos: 0
mi último intento...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:37.