Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/04/2007, 08:19
Avatar de reyesoft
reyesoft
 
Fecha de Ingreso: abril-2006
Ubicación: San Rafael, Mendoza
Mensajes: 311
Antigüedad: 18 años, 1 mes
Puntos: 15
Re: Saber la resolución del Cliente por PHP

Cuando necesites saber la resolución has lo siguiente entre el <body> y el </body>:

Código PHP:
include 'resolucion.inc.php'

resolucion.js

Código:
function SetCookie(obligar) {
    document.cookie = 'PHPRes='+screen.width + 'x' + screen.height;
    if (obligar == 1 && document.cookie != '')
        document.location.href=document.location.href;
}
function ChequearResolucion(ancho, alto) {
    if(ancho != screen.width && alto != screen.height) {
        SetCookie();
    }
}

resolucion.inc.php
Código PHP:
<script src="resolucion.js" type="text/javascript"></script>
<script type="text/JavaScript">
<!--
<?
    $res 
= array(0,0);
    if(isset(
$_COOKIE['PHPRes']) || !empty($_COOKIE['PHPRes']))
    {
        
$res explode("x",$_COOKIE['PHPRes']);
        
$resolucion = array(intval($res[0]), intval($res[1]));
        unset(
$res);
        echo 
'ChequearResolucion('.$resolucion[0].', '.$resolucion[1].');';
    } else {
        echo 
'SetCookie('.((isset($resolucion_obligar))?1:0).');
        '
;
    }
?>
//-->
</script>
Anda de lujo, yo lo uso en mi página de wallpapers.
__________________
Pablo Reyes

Compra/venta saldos PayPal, Skrill, Neteller, Bitcoins, etc.