Código:
El cual creo del siguiente modo:function oEditor (aNombreEditor) {
this.Nombre=aNombreEditor
this.Navegador=new oNavegador();
this.Contenido="";
this.ContenidoHTML="";
this.LineaActual=0;
this.ColumnaActual=0;
this.SelectorActual="";
//Métodos
this.OnTecla = OnTecla;
this.ActivarEditor= ActivarEditor;
//Ver si es editable
if (document.getElementById && document.designMode && !this.Navegador.esSafari && !this.Navegador.esKonqueror) {
this.esEditable= true;
} else {
this.esEditable= false;
}
//Incluir iframe con el Editor
if(this.esEditable){
document.writeln('<div id="iVerLineas" style="float:left;"></div>');
document.writeln('<iframe id="' + aNombreEditor + '"></iframe>');
}else{
//No funciona el aplicativo. LLamar a página de error.
}
Código:
En el método ActivarEditor pongo el iframe en modo edición, y le intento asignar un evento para cuando se pulsa una tecla. ...
<body>
<script language= "JavaScript" type= "text/javascript" src= "Aplicacion.js" ></script>
<script language= "JavaScript" type= "text/javascript" >
Ed= new oEditor("iEditor");
Ed.ActivarEditor();
</script>
</body>
...
Código:
El problema lo tengo en el 'this.OnTecla' ya que parece que el this no se refiere al objeto sino al contentdocument del iframe (visto desde Firefox).function ActivarEditor() {
//Pasar a modo diseño
if (this.Navegador.esIE) {
Ed = document.getElementById(this.Nombre).contentWindow.document;
Ed.write('<html><head></head><body></body></html>');
Ed.designMode = "on" ;
Ed.attachEvent('onkeyup', this.OnTecla);
}
else {
Ed = document.getElementById(this.Nombre).contentDocument;
Ed.write('<html><head></head><body></body></html>');
Ed.designMode = "on" ;
Ed.addEventListener("keyup", this.OnTecla, true);
}
}
function OnTecla() {
...
}
...
¿Como puedo hacer para que sea el objeto el que controle los eventos que se produzcan en el iframe?.
Gracias.

