Chrome Bug - window.scroll method intercepts DOM Rendering

做~自己de王妃 提交于 2020-01-14 05:01:34

问题


First, play with the navigation menu on this page (left-side): http://bestds.com/TankStorage/

I'm using javascipt to update the dom backgroundColor of these li elements upon click.

Firefox renders the updated DOM elements, but Chrom and Chromium do not render them.

Using Chromium's document inspector, I can clearly see that the li element's background-color has been updated correctly, but they're not being rendered. What's funny, is it will go ahead and render the DOM changes after I hover my my cursor over the unrendered html element in Chrom's document inspector!

How should I fix this?


回答1:


I figured it out. Chrom has a rendering bug.

If you call a window scroll function, immediately after you update some DOM properties, Chrom won't fully render all your DOM modifications.

To fix the problem, I replace this line:

window.scroll(0,docPos);

With this line:

setTimeout('window.scroll(0,' + docPos + ')',1);

This gives Chrom the ability to render the dom changes before the window-scroll-rendering bug can stop it.



来源:https://stackoverflow.com/questions/10924234/chrome-bug-window-scroll-method-intercepts-dom-rendering

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