Why is code after [removed]() not executed?

前端 未结 8 396
长情又很酷
长情又很酷 2021-01-21 07:36

I have the follwing JavaScript.


    
        

        
8条回答
  •  逝去的感伤
    2021-01-21 08:16

    You're destroying the DOM with your document.write call. In some browsers, this also destroys global variables.

    Instead use:

    var element = document.createElement('h1');
    element.appendChild(document.createTextNode('text'));
    document.body.appendChild(element);
    

提交回复
热议问题