none
“scrollHeight” not updated in “onscroll” event handler when using HtmlCtrl in an application but works correctly in IE RRS feed

  • Question

  • When sample below code loads in IE, it works correctly, but when loads in an html control in an application, 'scrollHeight' not updated in 'onscroll' event handler when I change the innerHTML content in the handler, and therefore the alert not to be displayed.

    <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>
    

    Saturday, April 28, 2012 6:40 AM

Answers