|
1 <!DOCTYPE html> |
|
2 <html class="reftest-wait"> |
|
3 <head> |
|
4 <script> |
|
5 |
|
6 function init1() |
|
7 { |
|
8 // Create an html:iframe in HTML mode (so designMode can be used 320092) |
|
9 targetIframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe'); |
|
10 targetIframe.src = "data:text/html,"; |
|
11 targetIframe.setAttribute("style", "width: 700px; height: 500px; border: 1px dotted green;"); |
|
12 targetIframe.addEventListener("load", init2, false); |
|
13 document.body.appendChild(targetIframe); |
|
14 } |
|
15 |
|
16 |
|
17 function init2() |
|
18 { |
|
19 targetWindow = targetIframe.contentWindow; |
|
20 targetDocument = targetWindow.document; |
|
21 |
|
22 p = document.getElementById("p"); |
|
23 pText = p.firstChild; |
|
24 |
|
25 targetDocument.body.appendChild(targetDocument.adoptNode(p, true)); |
|
26 |
|
27 targetDocument.designMode = 'on'; |
|
28 |
|
29 setTimeout(boom, 0); |
|
30 } |
|
31 |
|
32 |
|
33 function boom() |
|
34 { |
|
35 var rng = targetDocument.createRange(); |
|
36 rng.setStart(pText, 3); |
|
37 rng.setEnd(pText, 3); |
|
38 |
|
39 targetWindow.getSelection().addRange(rng); |
|
40 |
|
41 targetDocument.execCommand("insertorderedlist", false, null); |
|
42 |
|
43 document.documentElement.removeAttribute("class") |
|
44 } |
|
45 |
|
46 </script> |
|
47 </head> |
|
48 |
|
49 <body onload="init1();"> |
|
50 <p id="p">word word</p> |
|
51 </body> |
|
52 |
|
53 </html> |