Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Obtenga el elemento activo en el documento cuando el cuerpo contenteditable="true"

Estoy probando lo siguiente en el navegador de borde, pero en última instancia estoy tratando de hacer que esto funcione dentro de un control de navegador web activex en un formulario "shellExplorer.2"

Solo estoy tratando de hacer esto de forma nativa, así que no quiero la solución jquery.

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>JS Bin</title> <script type="text/javascript"> function docode() { console.log(document.activeElement.tagName); } </script> </head> <body onclick="docode();" contentEditable="true"> <div tabindex=1>Here</div> <div>Nothing here</div> <div contenteditable>Something here</div> <table> <tr> <td> test text </td> <td> test 2</td> </tr> </table> </body> </html>

Tengo el html anterior. En última instancia, necesito saber en qué elemento se hace clic para poder averiguar si el elemento está dentro de una tabla, por ejemplo. (Mi antiguo código funcionó y subo por los nodos principales hasta que llego a una tabla o una etiqueta de cuerpo.

Todo lo que parece obtener es "CUERPO". A veces puedo tener suerte y obtener un DIV para el div con tabindex.

Probé la siguiente función y eso simplemente devuelve "indefinido"

 function docode() { var ovar = window.getSelection(); var orange = ovar.getRangeAt(0); console.log(orange.tagname); }

getSelection() y getRangeAt(0) solían funcionar, pero parece que Microsoft ha cambiado algo en el control.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!