IE10 JavaScript cannot repaint window while computer is locked?

妖精的绣舞 提交于 2019-12-05 04:29:14

Finally found a way to overcome this ridiculous annoyance. I added some JavaScript to my auto-logout landing page (where I was redirecting the users). This JavaScript updates the page content every one second.

Voila!

The real issue here is that even if the IE10 window content was legitimately updated and ought to repaint (such as when a redirect occurs) while the computer was locked..... it will not repaint.

IE10 only repaints if the page content update action occurs WHILE the computer is unlocked.

The JavaScript below updates the page content every one second, by setting the DIV's content to the current time, including seconds. This means if the user locks their computer and goes to lunch for an hour, their browser page will be timed out and redirected to the logout page while they are gone. When the user comes back and unlocks their computer... they will see the old stale content for 1 second.... and then the running JavaScript forces a repaint, and they will quickly see the logout screen's content.

<h1>Due to inactivity, you were automatically logged out.  (Deal with it.)</h1>
<div id="div1" style="background-color: white; color: white;">
</div>
<script>
    (function ()
    {
        var forceRepaint = function ()
        {
            var myDiv = document.getElementById("div1");
            myDiv.innerHTML = new Date().toLocaleTimeString();
        };
        setInterval(forceRepaint, 1000);
    })();
</script>

I did try things like just setting the visibility on the DIV to make it hidden (instead of setting white background and white text color), but the browser will not repaint. It's very intelligent about detecting if a visible change has really occurred.

BONUS -- Yahoo/Google versus my Logout page

The reason I could not create the issue when redirecting to external sites like Yahoo or Google was that they probably had some JavaScript code running that would indeed update their page's content after it had loaded. They essentially had more 'stuff' going on. Whereas my original logout page was very plain and did not have any JavaScript code executing on page load.

I suspect this might be specific to particular set of graphics cards or drivers. From the IE menu bar, select Internet Options. On the advanced tab, select the "Use software rendering" option. Then reboot.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!