Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/04/2012, 07:31
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 16 años, 7 meses
Puntos: 1012
Respuesta: agregar y quitar archivos estilos css

anoche me cegó la idea de Melecio de remover el include.

emprear, permiteme usar tu código. se trata de sobrescribir el atributo href del include una vez creado
Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cambiar Estilos</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
//<![CDATA[
window['bol'] = 0;
function cambiaEstilos(nombre){
window['bol'] = window['bol'] == 0 ? 1 : 0;

if(window['bol']){ // agregar estilos
var elCss = document.createElement('link');
elCss.rel = 'stylesheet'
elCss.type = 'text/css';
elCss.href = nombre + '.css';
document.getElementsByTagName('head')[0].appendChild(elCss);
}else { //remover estilos
document.getElementsByTagName('head')[0].getElementsByTagName('link')[0].href = nombre + '.css';
window['bol'] = 1;
}
}

//]]>
</script>
</head>
<body>
<h1>Hola</h1>
<!-- parámetros para la función, nombre del archivo css sin extensión, a para agregar, r para remover -->
<button onclick="cambiaEstilos('original');">Agregar estilo original.css</button>
<button onclick="cambiaEstilos('verde');">Agregar estilo verde.css</button>
</body>
</html>
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}