Ver Mensaje Individual
  #14 (permalink)  
Antiguo 17/08/2009, 05:54
Avatar de sweetlydark
sweetlydark
 
Fecha de Ingreso: septiembre-2008
Mensajes: 391
Antigüedad: 15 años, 7 meses
Puntos: 10
Respuesta: No funciona createRange en IE8

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>
__________________
Por fin vuelvo a tener internet!
http://www.anidandoetiquetas.com/