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