Below is a snippet of jQuery code that I'm working with:
<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() {
// Checking if body height exceeds window height
if ($(document).height() > $(window).height()) {
hasVBar="y";
}
// Checking if body width exceeds window width
if ($(document).width() > $(window).width()) {
hasHBar="n";
}
});
</script>
In my HTML page, the first div is 200px in height, followed by another div containing 3 paragraphs each within different divs. These 3 paras are shown or hidden using JavaScript onclick. The issue arises when even if these 3 divs are hidden (display:none and visibility:hidden), the vertical scrollbar still shows up. I expect the vertical scrollbar to only appear when the combined height of those 3 divs is enough to exceed the window height. Especially when all 3 divs are hidden initially.
I hope this clarifies my question. Any suggestions would be greatly appreciated. Thank you 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>