AboutAndrew Hoffman Expertise I can field just about any question within this topic ranging from JavaScript to CSS, the two ingredients of DHTML. I`m very interested in the W3C and its validation rules for HTML, XHTML, and CSS, and enjoy answering questions of this type as well. I detest sleep and respond at all hours of the day or night.
Experience Experience in the area I've been working with DHTML and CSS for 7 years now and build/maintain websites of my own that implement DHTML navigation.
What I'm doing now My contract with Microsoft has ended and I am working for myself once again. Please contact me for any front-end work at antibland@gmail.com
Question I have a site that has a top and left static navigation pane. Using JavaScript, I've been able to determine the width and height of the browser client window and to adjust those values to account for the navigation panes. However, when it comes to defining the data region's width and height in a div, I cannot seem to figure out how to get the JavaScript values into the div element. Help!
Where "width" and "height" are temporary hard-coded values that need to be dynamic, based on what's leftover from a visitor's browsing session (based on their preferred sizing for their browser).
The JavaScript used to get the client window sizes is:
function getClientWidth() {
return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function getClientHeight() {
return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
... and the calculated available space is a simple math calculation (remove 187 from width and 54 from height). What do I do to put dynamic width and height values into the div?
Thanks in advance.
Answer Hi Kehvan,
You probably forgot to add "px" after the desired height or width value. Without it, the dimensions of the div won't change. Run the simple example below to see what I'm talking about.