For your situation the following code may work just as well. It is very simple and doesn't make all the checks that the other code does. Also, it will only work with pixel sizes.
Code:
<!--[if lt IE 7]>
<script type="text/javascript">
window.attachEvent('onload', function() { ieMinMax('test3', 400, 600); });
function ieMinMax(id, min, max)
{
var e = document.getElementById(id);
if (e) {
setInterval(
function() {
var w = document.documentElement.clientWidth;
if (w < min) {
e.style.width = min + 'px';
}
else if (w > max) {
e.style.width = max + 'px';
}
else {
e.style.width = 'auto';
}
//window.status = w + ' / ' + e.offsetWidth;/////////////
}, 500 // run twice per second
);
}
}
</script>
<![endif]-->
I threw this together quickly so, if you use it, please test it well.
Instead of using "document.documentElement.clientWidth" you might want to use something like xClientWidth
Bookmarks