Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: basickdagger en 5 Septiembre 2011, 20:17 pm



Título: scrollbar hidden
Publicado por: basickdagger en 5 Septiembre 2011, 20:17 pm
hola!

hay alguna manera de utilizar el scroolbar:hidden y que en algun punto(cuando se haga demasiado chica la pantalla) el scrollbar se active???? con alguna funcion de javascript??  osea q cuando llegue a tantots pixeles se active el scrollbar?


Título: Re: scrollbar hidden
Publicado por: madpitbull_99 en 5 Septiembre 2011, 20:35 pm
Con javascript puedes detectar el tamaño de la ventana del navegador, y luego haces un script que comprueba si la ventana tiene mas de "X" valor, entonces cambias el estilo de un div (o de todo el body) y activas el scroll.


Código
  1. <script type="text/javascript">
  2. <!--
  3.  
  4. /* Detectar ventana navegador crossbrowser */
  5.  
  6. var viewportwidth;
  7. var viewportheight;
  8.  
  9. // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  10.  
  11. if (typeof window.innerWidth != 'undefined')
  12. {
  13.      viewportwidth = window.innerWidth,
  14.      viewportheight = window.innerHeight
  15. }
  16.  
  17. // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  18.  
  19. else if (typeof document.documentElement != 'undefined'
  20.     && typeof document.documentElement.clientWidth !=
  21.     'undefined' && document.documentElement.clientWidth != 0)
  22. {
  23.       viewportwidth = document.documentElement.clientWidth,
  24.       viewportheight = document.documentElement.clientHeight
  25. }
  26.  
  27. // older versions of IE
  28.  
  29. else
  30. {
  31.       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
  32.       viewportheight = document.getElementsByTagName('body')[0].clientHeight
  33. }
  34. //document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
  35.  
  36. /* Detectar ventana navegador crossbrowser */
  37.  
  38. if ((viewportwidth > 800) && (viewportheight > 800) {
  39.   // Cambiamos el estilo y activamos el scroll
  40.    $('body').css('overflow',scroll);
  41.  
  42. }
  43.  
  44.  
  45. //-->
  46. </script>
  47.  


Para la última parte, lo he hecho con JQuery, lo demás es de un ejemplo de Google.


Título: Re: scrollbar hidden
Publicado por: basickdagger en 7 Septiembre 2011, 20:10 pm
gracias, aunq al final mejor utilice overflow-x:hidden al fin y al cabo no hay resoluciones tan pequeñisimas haha gracias por la ayuda