De verdad? Esto me funciona:
Inserta texto con IE8
Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>AEInbetween.com</title>
<script>
function x()
{
//oSel=this.selection
var iframe = document.getElementById('Editor');
var doc = iframe.contentWindow.document;
//if (!oSel) {
document.frames['Editor'].tester.focus();
return oSel = doc.selection.createRange();
//oSel.type = Editor.document.selection.type
//}
}
function insertarHTML(sHTML)
{
var sType
//llamo a la funcion que me da la selección
var sel =x();
//sType = sel.type
//if (sType=="Control")
//sel.item(0).outerHTML = sHTML
//else
//{
sel.pasteHTML(sHTML);
}
</script>
</head>
<body>
<iframe id="Editor" name="Editor" src="test.html" width="100%" height="200px"></iframe>
<button onclick="insertarHTML('sHTML')">Try Me</button>
</body>
</html>
test.html
Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>AEInbetween.com</title>
</head>
<body>
<div name="tester" id="tester" contenteditable="true">test with this text</div>
</body>
</html>