JavaScript TypeError: Cannot read property 'style' of null

前端 未结 6 1912
一向
一向 2020-11-30 00:25

I have JavaScript code and below line has problem.

if ((hr==20)) document.write(\"Good Night\"); document.getElementById(\'Night).style.display=\'\'
<         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 01:08

    I met the same problem, the situation is I need to download flash game by embed tag and H5 game by iframe, I need a loading box there, when the flash or H5 download done, let the loading box display none. well, the flash one work well but when things go to iframe, I cannot find the property 'style' of null , so I add a clock to it , and it works

    let clock = setInterval(() => {
            clearInterval(clock)
            clock = null
            document.getElementById('loading-box').style.display = 'none'
        }, 200)
    

提交回复
热议问题