Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/04/2013, 19:20
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Como determinar el ancho del browser

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="es-ar">
  3. <meta charset="utf-8" />
  4. <title>Html5</title>
  5.  
  6. <script type="text/javascript">
  7. //<![CDATA[
  8. function medidas(){
  9. var winW,winH;
  10. if (document.body && document.body.offsetWidth) {
  11. winW = document.body.offsetWidth;
  12. winH = document.body.offsetHeight;
  13. }
  14. if (document.compatMode=='CSS1Compat' &&
  15.    document.documentElement &&
  16.    document.documentElement.offsetWidth ) {
  17. winW = document.documentElement.offsetWidth;
  18. winH = document.documentElement.offsetHeight;
  19. }
  20. if (window.innerWidth && window.innerHeight) {
  21. winW = window.innerWidth;
  22. winH = window.innerHeight;
  23. }
  24.  
  25.  
  26. document.getElementById('ancho').innerHTML = winW;
  27. document.getElementById('alto').innerHTML = winH;
  28. }
  29. //]]>
  30.  
  31. </head>
  32. <body onload="medidas();" onresize="medidas();">
  33. <div>Ancho: <span id="ancho"></span></div>
  34. <div>Alto: <span id="alto"></span></div>
  35. </body>
  36. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.