Click to See Complete Forum and Search --> : frame look


vinays84
03-15-2007, 10:30 AM
Is there anyway to achieve the frame look in one page without using frames? I have a JSP page in which i'd like that top part to always remain at the top, and the bottom scrollable. However, both parts use the same request and same global variables (created from the request) within the page.

TheBearMay
03-15-2007, 11:34 AM
Easiest way is to put them in separate div's and then make the bottom one a fixed height with overflow:auto.


<div> Header content </div>
<div style="height:36em; overflow:auto">Scrollable Content</div>

vinays84
03-15-2007, 02:49 PM
Thanks.. that works. Is there anyway to find out the height of the top div after its is built and before the bottom is built, so that the height of the bottom can be allocated to just fit within the page (avoiding the outer scroll bar)?

TheBearMay
03-16-2007, 02:29 PM
We can apply a little javascript and adjust it when the document loads or resizes:

<script type="text/javascript">
window.onload = resizeWin;
window.onresize = resizeWin;
var resizeTime = new Date() - 5000;

function resizeWin() {
if (new Date() - resizeTime > 100) resizeTime = new Date();
else return false;

var winH;
if (window.innerHeight) winH=window.innerHeight;
else winH=document.body.offsetHeight;

var percentAdj=((winH-document.getElementById("container").offsetTop)-20)+"px";
document.getElementById("container").style.height=percentAdj;
return true;
}
</script>
...
<div> Header content </div>
<div style="overflow:auto" id="container">Scrollable Content</div>