How to display a constantly changing image file in a browser without refresh flicker?

前端 未结 3 2091
南旧
南旧 2021-02-05 12:56

I\'m displaying an image (from a file) on the browser using html... I have another program that keeps taking a screenshot of my screen and storing it as an image file \"image.jp

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 13:19

    I think you don't need to create the Image object every time in timedRefresh(). Just create one instance and constantly change its src attribute. In case of your code snippet, img would have to be global variable.

    The main problem, though, is that you will still see flickering (but of different kind) in Opera. See: Image source update in JavaScript with Opera

提交回复
热议问题