The intent of this script is to make a DIV that is 100% of the page height minus the top section.
Here’s the page:
http://nerdi.net/playground/kev/indexNEW.html
Here it is stripped down on jsFiddle, where it appears to be working.
For me, (on Chrome and FF) the scrollable div (.mid-col-main) only becomes scrollable upon resizing the window (Maximize, drag from corner, etc)
Any idea what I’m doing wrong?
EDIT: Jasper and Davin’s solution both work. Thank you.
You need to wait for the DOM to be ready, basically you were running the code too soon and
div.mid-col-mainis not available yet:Here I have placed your binding code inside a
document.readyevent handler and also triggered aresizeevent on thewindowelement. I also optimized your code a bit to cache things that don’t change (you don’t need to select the same element everyresizeevent).Instead of running this code in a
document.readyevent handler, you could put this code at the end of the HTML document (just before the closing</body>tag), that way the element you want to target will be available.