javascript中document.appendChild和document.body.appendChild的问题

在IE7中

var conentDiv = document.createElement("div");

 document .body .appendChild(conentDiv);

 document .appendChild(conentDiv);

都不会报错,但是在IE11中

 document .appendChild(conentDiv);会报错:javascript runtime error:HierarchyRequestError

由于 div是document .body的子元素,而不是 document的子元素。

原文地址:https://www.cnblogs.com/huaan011/p/5526906.html