Well, I'm assuming then that the dynamic content is imported via some type of javascript, perhaps including AJAX. In any case, if javascript is involved, at least in IE, one may set the table's style.height property to its offsetHeight property + 'px'. In limited tests here, this works for IE, but not for Opera. In Opera one must iterate over all elements involved that have 100% height and set each of them to their respective offsetHeight + 'px'.
Unfortunately, any method for doing so would either have to be applied to all browsers, or rely upon some sort of browser sniffing, or possibly rely upon a test or tests (assuming the layout is similar) of the the division's offsetHeight as compared to the preceding td's offsetHeight. None of these is really ideal. The first is unnecessary, the second may cause problems in the future, and the third might not work, or might become complex to execute, though if it does work out is the preferred method.
Using the second method (browser sniffing), I came up with this code which solves your original example, but that would need to be adapted to what you are now talking about:
Code:
<script type="text/javascript">
if(window.attachEvent){
window.attachEvent('onload', function(){
var els = document.all || document.getElementsByTagName('*'), l = els.length, i = 0;
for(i; i < l; ++i){
if((window.opera || els[i].parentNode === document.body) && els[i].currentStyle && els[i].currentStyle.height === '100%'){
els[i].style.height = els[i].offsetHeight + 'px';
}
}
});
}
</script>
If I were to help you adapt it to your actual situation though, I'd want to see the code, preferably the page itself live:
Please post a link to the page on your site that contains the problematic code so we can check it out.
That said, the function itself:
Code:
function percentHeight(){
var els = document.all || document.getElementsByTagName('*'), l = els.length, i = 0;
for(i; i < l; ++i){
if((window.opera || els[i].parentNode === document.body) && els[i].currentStyle && els[i].currentStyle.height === '100%'){
els[i].style.height = els[i].offsetHeight + 'px';
}
}
}
could be run each time content is imported (after it arrives and is inserted into the document), perhaps with good result. Except that the condition els[i].currentStyle.height === '100%' would no longer be true after the first run, unless the javascript style.height were peremptorily removed each time and all heights were set in the stylesheet.
Bookmarks