5 var style
= document
.createElement("style");
8 var output
= document
.createElement("output");
11 var input
= document
.createElement("input");
14 var script
= document
.createElement("script");
17 var clonedOutput
= output
.cloneNode(false);
20 document
.documentElement
.appendChild(style
);
23 style
.outerHTML
= '<a contenteditable="true">';
25 // For emulating the traditional behavior, collapse Selection to end of the
26 // <body> which must be empty (<style> was added after the <body>).
27 getSelection().collapse(document
.body
, document
.body
.childNodes
.length
);
29 document
.documentElement
.appendChild(input
);
32 var text
= document
.createTextNode(" ");
35 script
.appendChild(text
);
38 document
.documentElement
.appendChild(script
);
41 var selection
= getSelection();
47 document
.replaceChild(document
.documentElement
, document
.documentElement
);
50 selection
.setBaseAndExtent(text
, 0, clonedOutput
, 0);
53 document
.designMode
= "on";
56 document
.execCommand("insertImage", false, "http://localhost/");