"scrollHeight" is not updated in the onscroll event handler when using HtmlCtrl in the application, but it works correctly in IE9

When the sample below loads in IE9, it works correctly, but when it loads into the html control in the application, 'scrollHeight' is not updated in the onscroll event handler when the contents of innerHTML change in the handler and therefore the warning is not displayed.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script>
function f()
{
    var nBodyHeightOld = document.getElementById("div1").scrollHeight;
    document.getElementById("div1").innerHTML += '<div>It is a test!</div>';
    if (document.getElementById("div1").scrollHeight != nBodyHeightOld)
        alert('scrollHeight changed!');
}
</script>
</head>
<body>
<div id='div1' style='overflow:scroll; height:300px' onscroll="f()">
    <div style='height:400px'></div>
</div>
</body>
</html>
+3
source share
1 answer

Do not use an application using IE8. To force the application to use IE9, add a meta tag to the html:

<meta http-equiv="X-UA-Compatible" content="IE=9" >
+1
source

All Articles