scrollbar hidden

Iniciado por basickdagger, 5 Septiembre 2011, 20:17 PM

0 Miembros y 1 Visitante están viendo este tema.

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 (javascript,38,39,40) [Seleccionar]

<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.



«Si quieres la paz prepárate para la guerra» Flavius Vegetius


[Taller]Instalación/Configuración y Teoría de Servicios en Red

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