scrollbar hidden

(1/1)

basickdagger:
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?

madpitbull_99:
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
<script type="text/javascript">
<!--
 
/* Detectar ventana navegador crossbrowser */
 
var viewportwidth;
var viewportheight;
 
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
if (typeof window.innerWidth != 'undefined')
{
     viewportwidth = window.innerWidth,
     viewportheight = window.innerHeight
}
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 
else if (typeof document.documentElement != 'undefined'
    && typeof document.documentElement.clientWidth !=
    'undefined' && document.documentElement.clientWidth != 0)
{
      viewportwidth = document.documentElement.clientWidth,
      viewportheight = document.documentElement.clientHeight
}
 
// older versions of IE
 
else
{
      viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      viewportheight = document.getElementsByTagName('body')[0].clientHeight
}
//document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
 
/* Detectar ventana navegador crossbrowser */
 
if ((viewportwidth > 800) && (viewportheight > 800) {
  // Cambiamos el estilo y activamos el scroll
   $('body').css('overflow',scroll);
 
}
 
 
//-->
</script>
 


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

basickdagger:
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

Navegación

[0] Índice de Mensajes