Hola
pantxo :
Esta pregunta ya la hicieron y en su momento no la pude responder.
En realidad no hay un método javascript que lo haga. Pero siempre se puede inventar algo. Lo probé en
IE y
Firefox (aunque en este último el botón de prueba no funciona).
[edit]
Actualicé el ejemplo para más navegadores.
El
textarea con el progreso de las variables y comentarios se puede eliminar, está destacado con tabulaciones.
[/edit]
Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>DETECTA SCROLLBAR.</title>
<script type="text/javascript">
var anC1, anC2, alC1, alC2;
var lista = "";
function medir1(){
document.body.style.overflow="hidden";
anC1=document.body.clientWidth;
alC1=document.body.clientHeight;
lista = lista + "anC1 : "+anC1+" /Sin ScBr/; ";
document.body.style.overflow="auto";
setTimeout("medir2()",100)
}
function medir2(){
anC2=document.body.clientWidth;
alC2=document.body.clientHeight;
lista = lista + "anC2 : "+anC2+" /Con ScBr/ . \r\n";
document.getElementById("txt").focus();
document.getElementById("txt").value = lista +"\t(Grosor="+ (anC1-anC2) +"px) \r\n";
if((anC1!=anC2) || (alC1!=alC2)) alert("Hay scrollbar.");
else alert("No hay scrollbar.")
}
</script>
<style type="text/css">
body, html {width: auto; background-color: #808080; }
img {vertical-align: top; width: 1px; height:110%; }
</style>
</head>
<body onload="medir1()">
<h2>Detecta la existencia de barras de desplazamiento. IE8.0, FF3.6, Chr8.0, Op11.0</h2>
<p>
<input type=button value="Con / sin scrolbar" onclick="if(document.getElementById('alfa').style.height == '50%') document.getElementById('alfa').style.height='110%'; else document.getElementById('alfa').style.height='50%'" >
<input type=button onclick=medir1() value="Detectar" >
<br>
<img src="http://static.forosdelweb.com/fdwtheme/images/statusicon/subforum_old.gif" id=alfa >
<textarea id=txt style="width:80%; height:6em">
</textarea>
</p>
</body>
</html>
Sólo sácame de una duda : ¿para qué lo usas?
saludos
furoya
Comprobar si hay barra lateral de scroll