Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/11/2008, 01:23
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
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>