|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <script> |
|
5 |
|
6 function boom() |
|
7 { |
|
8 var root = document.documentElement; |
|
9 |
|
10 while (root.firstChild) { root.removeChild(root.firstChild); } |
|
11 |
|
12 var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body"); |
|
13 var div = document.createElementNS("http://www.w3.org/1999/xhtml", "div"); |
|
14 root.contentEditable = "true"; |
|
15 root.appendChild(div); |
|
16 root.removeChild(div); |
|
17 root.insertBefore(body, root.firstChild); |
|
18 |
|
19 window.getSelection().removeAllRanges(); |
|
20 var r0 = document.createRange(); |
|
21 r0.setStart(body, 0); |
|
22 r0.setEnd(body, 0); |
|
23 window.getSelection().addRange(r0); |
|
24 var r1 = document.createRange(); |
|
25 r1.setStart(div, 0); |
|
26 r1.setEnd(div, 0); |
|
27 window.getSelection().addRange(r1); |
|
28 |
|
29 document.execCommand("inserthtml", false, "1"); |
|
30 } |
|
31 |
|
32 </script> |
|
33 </head> |
|
34 |
|
35 <body onload="boom();"></body> |
|
36 </html> |