I have a lil piece of jqery code here:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
hasVBar="";
hasHBar="";
$(document).ready(function() {
// Check if body height is higher than window height :)
if ($(document).height() > $(window).height()) {
// alert("Vertical Scrollbar! D:");
hasVBar="y";
}
// Check if body width is higher than window width :)
if ($(document).width() > $(window).width()) {
//alert("Horizontal Scrollbar! D:<");
hasHBar="n";
}
});
</script>
Now in my html page first div is 200px in height, below that is another div that contains 3 paras each in different div. I show hide these 3 paras by javascript onclick. The problem is even if these 3 divs are in hidden state (display:none and visibility:hidden) the vertical scroll bar shows up. Where as I am expecting vertical scrollbar to pop up only if any combination of those 3 divs is sufficient enough to make the height of the document higher than the window height. Atleast initially when the page is opened (all 3 divs in hidden state then).
I hope I have been able to make my query clear. Any suggestions ??? Thanks.. in advance...
window.onload=function starterJobs(){
document.getElementById('abtpri').style.visibility='hidden';
document.getElementById('abtpri').style.display='none';
}
<script type="text/javascript">
function hidePara(whichId) {
showhide = document.getElementById(whichId).style.display;
if (showhide=='block') {
document.getElementById(whichId).style.display='none';
document.getElementById(whichId).style.visibility='hidden';
} else {
document.getElementById(whichId).style.display='block';
document.getElementById(whichId).style.visibility='visible';
}
}
</script>
<div style=" position:relative;background:none; width:auto; height:25px; padding:10px 0px 10px 0px;">
<div style="position:relative; top:0px; left:0px; background:transparent url(lftarw.gif) no-repeat; width:25px; height:25px; cursor:pointer" onclick="hidePara('abtpri'); "></div>
<div id="printing1" class="h1type4" style="position:relative; top:-25px; left:25px; background-color:none; width:auto; height:20px; padding-top:5px; margin-right:25px;">Printing</div>
</div>
<div id="abtpri" style="padding-left:25px;">
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
</div>