insertparentandchild.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <html class="reftest-wait">
  2. <head>
  3. <script>
  4. function boom()
  5. {
  6. document.body.offsetHeight;
  7. var sixdiv = document.getElementById("six");
  8. var parent = sixdiv.parentNode;
  9. var newdiv = document.createElement("div");
  10. var childdiv = document.createElement("div");
  11. childdiv.appendChild(document.createTextNode("5c"));
  12. newdiv.appendChild(childdiv);
  13. childdiv = document.createElement("div");
  14. childdiv.appendChild(document.createTextNode("5d"));
  15. newdiv.appendChild(childdiv);
  16. parent.insertBefore(newdiv, sixdiv);
  17. childdiv = document.createElement("div");
  18. childdiv.appendChild(document.createTextNode("5b"));
  19. newdiv.insertBefore(childdiv, newdiv.firstChild);
  20. childdiv = document.createElement("div");
  21. childdiv.appendChild(document.createTextNode("5a"));
  22. newdiv.insertBefore(childdiv, newdiv.firstChild);
  23. document.body.offsetHeight;
  24. document.documentElement.className = "";
  25. }
  26. </script>
  27. </head>
  28. <body onload="boom();">
  29. <div>1</div>
  30. <div>2</div>
  31. <div>3</div>
  32. <div>4</div>
  33. <div id="six">6</div>
  34. <div>7</div>
  35. <div>8</div>
  36. <div>9</div>
  37. </body>
  38. </html>