Foros del Web » Programando para Internet » Javascript »

detectar si css está activo

Estas en el tema de detectar si css está activo en el foro de Javascript en Foros del Web. como? P.D. lamento la simplicidad pero no se necesita un discurso....
  #1 (permalink)  
Antiguo 04/11/2008, 22:27
Avatar de killerangel  
Fecha de Ingreso: septiembre-2007
Ubicación: Un punto en el espacio
Mensajes: 592
Antigüedad: 16 años, 7 meses
Puntos: 10
detectar si css está activo

como?

P.D. lamento la simplicidad pero no se necesita un discurso.
__________________
Sueñen... y trabajen por hacer esos sueños realidad... de eso se construye el futuro!!
Me siento entre la ASP-ada y la PHP-red
  #2 (permalink)  
Antiguo 05/11/2008, 01:23
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 19 años, 11 meses
Puntos: 834
Respuesta: detectar si css está activo

1)Con ayuda de lenguaje de servidor:
Código PHP:
<?php
session_start
();
if(isset(
$_GET['im'])){
header("Content-type:image/gif");
$im='R0lGODlhlgAyAIAAAP///wAAACH5BAEAAAAALAAAAACWADIAAAJghI+py+0Po5y02ouz3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8YhMKpfMpvMJjUqn1Kr1is1qt9yu9wsOi8fksvmMTqvX7Lb7DY/L5/S6/Y7P6/f8/r4AADs=';
echo 
base64_decode($im); 
$_SESSION['activado']='si';
exit;
}
if(isset(
$_GET['verificar'])){
if(
$_SESSION['activado']=='si'){
echo 
'
alert("css activado");
'
;
}else{
echo 
'
alert("css desactivado");
'
;
}

exit;
}
if(isset(
$_GET['recargar'])){
$_SESSION['activado']='no';
exit;
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ver css</title>
<script>
function rpc(url){
    oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);
}  
function addCss(cssCode,i) {
    control=document.getElementById(i)
    if(control)
        document.getElementsByTagName("head")[0].removeChild(control)
    var styleElement = document.createElement("style");
    styleElement.type = "text/css";
    if (styleElement.styleSheet) {
        styleElement.styleSheet.cssText = cssCode;
    } else {
        styleElement.appendChild(document.createTextNode(cssCode))
    }
    styleElement.id =i;
    document.getElementsByTagName("head")[0].appendChild(styleElement);
}
window.onload=function(){
rpc('<?php echo basename($_SERVER['PHP_SELF']) ?>?recargar');
old=document.getElementById("pp");
       if(old)
            document.getElementsByTagName("body")[0].removeChild(old);
o=document.createElement('div');
o.id='pp';
o.className='ver';
document.getElementsByTagName('body')[0].appendChild(o);
cssCode='.ver{background:url(<?php echo basename($_SERVER['PHP_SELF']) ?>?im);}';
addCss(cssCode,'tester');
setTimeout("rpc('<?php echo basename($_SERVER['PHP_SELF']) ?>?verificar')",200);


}
</script>
</head>

<body>
</body>
</html>
2)CSS y Modelo de Cajas Correcto (importante usar doctype adecuado):
Código PHP:
<!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>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>test</title>
<
script>
function 
testBoxModel(){
    var 
test document.createElement('div');
    
test.style.visibility 'hidden';
    
test.style.width '100px';
    
test.style.padding '100px';
    
document.getElementsByTagName('body')[0].appendChild(test);
    var 
test.offsetWidth || 0;
    if(
w!=300) {return false;}
    
document.getElementsByTagName('body')[0].removeChild(test);
    return 
true;
}
onload=function(){
    if(!
testBoxModel()){alert('incorrecto modelo de cajas o css desactivado');}
}
</script>
</head>

<body>
</body>
</html> 
  #3 (permalink)  
Antiguo 05/11/2008, 10:26
Avatar de killerangel  
Fecha de Ingreso: septiembre-2007
Ubicación: Un punto en el espacio
Mensajes: 592
Antigüedad: 16 años, 7 meses
Puntos: 10
Respuesta: detectar si css está activo

gracias!!!!!
__________________
Sueñen... y trabajen por hacer esos sueños realidad... de eso se construye el futuro!!
Me siento entre la ASP-ada y la PHP-red
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 13:31.