Todas las mentes viagra generico espana del mundo cialis generico espana recomiendan viagra contrareembolso prevenir problemas cialis contrareembolso

Muchas veces nos encontramos que nuestra web no está preparada para una versión móvil (ya sea porque tiene flash o porque el diseño se ve muy pequeño…). Pues tenemos la solución muy sencilla:

<script type="text/javascript">
var deviceiphone = "iphone";
var deviceipod = "ipod touch";
var deviceandroid = "android";
var uagent = navigator.userAgent.toLowerCase(); //Initialize our user agent string to lower 
 
case.function Detectiphone(){ // Detects if the current device is an iphone.
    if (uagent.search(deviceiphone) > -1){
        return true;
    }else{
        return false;
    }
}
function Detectipod(){// Detects if the current device is an ipod Touch.
    if (uagent.search(deviceipod) > -1){
        return true;
    }else{
        return false;
    }
}
function Detectandroid(){// Detects if the current device is an ipod Touch.
    if (uagent.search(deviceandroid) > -1){
        return true;
    }else{
        return false;
    }
}
function DetectDevice(){// Detects if the current device is an iphone or ipod Touch.
    if ((Detectiphone())||(Detectipod())||(Detectandroid())){
        window.location =/mobile/;
    }
}
if ((Detectiphone())||(Detectipod())||(Detectandroid())){
    window.location ="/mobile/";
}
</script>

Pegamos esto en nuestro <head>. Luego en el tag <body> la llamada a la función (sin esto, aún teniendo el código del head, no funcionaría) de esta forma:

<body onLoad="DetectDevice()">

¡Y listo! así nuestra web o blog si detecta que se trata de uno de los dispositivos configurados en nuestro redireccionamiento, les llevará a una sección determinada.

Nota: Si averiguamos los nombres de otros dispositivos (tales como el del iPad o BlackBerry… que son unos nombres en especial) podremos redireccionar detalladamente cada dispositivo.

Categorías: JavaScript
Etiquetas:
Si necesitas una url corta puede usar: codygo.es/21

7 comentarios

  1. […] Esto combinado con la detección de dispositivos móviles, que ya comenté en su día, hace de sustitutivo perfecto a una aplición para leer un blog o página web. […]

  2. Wow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is wonderful, let alone the content!

  3. I’m nonetheless learning from you, however I’m improving myself. I definitely love reading the whole lot that’s written in your blog.Keep the stories coming. I liked it!

  4. vigrx scam dice:

    This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want…HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!

  5. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you achieve experience, would you mind updating your blog with extra data? This can be very helpful for me.

  6. Very nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed browsing your blog posts. After all I’ll be subscribing to your rss feed and I hope you write again soon!

  7. Related Site…

    […]Wonderful story, reckoned we could combine some unrelated information, nevertheless actually really worth taking a look, whoa did one particular discover about Mid East has got additional problerms at the same time […]…

Deja un comentario