Yo donde tengo el problema con mi script es en Mozilla, en IE funciona perfectamente. La cuestión es que yo no utilizo un TEXTAREA, sino una página metida en un iframe.
EIDTO: ya lo tengo, os pongo el código corregido por si le interesa a alguien. Como veréis, sólo ha cambiado una pequeña cosa.
Código HTML:
<iframe src="blank.html" id="areaEditable" style="width:500px; height: 300px; border-style:inset; border-width:thin;" frameborder="0px"></iframe><br>
<input type="button" value="Ver contenido" onClick="javascript:alert( verContenido() );" />
<input type="button" value="Ver selección" onClick="javascript:alert( verSeleccion() );" />
<script language="JavaScript" type="text/JavaScript">
function verContenido() {
//Para IExplorer
if (window["areaEditable"]){
return window["areaEditable"].document.body.innerHTML;
//Para Mozilla
}else{
return document.getElementById("areaEditable").contentWindow.document.body.innerHTML;
}
}
function verSeleccion(){
//Para IExplorer
if(typeof document.selection != 'undefined' && document.selection) {
return window["areaEditable"].document.selection.createRange().text;
}
//Para Mozilla
else if(document.getElementById("areaEditable").selectionStart != 'undefined'){
return document.getElementById("areaEditable").contentWindow.getSelection();
}
}
</script>