Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
How can I freeze all DOM changes with JS?

How can I freeze all JS DOM changes completely using JS from a chrome extension?

Example: a user hovers over a button, which onMouseEnter displays a modal and hides it onMouseLeave. If I bind a callback to a certain keyboard-shortcut, how can I freeze the DOM in that point in time so that the modal stays visible and nothing can change in the DOM anymore (until the shortcut is pressed again) ?

I know there might not be a direct API to freeze the DOM, but I'm looking for any ideas that can help me do this.

One Idea I tried was:

  • When user presses the shortcut (toggles the freeze on)
    • grab the html node in current state
      • query and remove all script nodes
      • clone the html node (to get rid of bound listeners)
    • replace actual html node with the cleaned-out cloned html node (one without js scripts)
  • When user presses the shortcut again (toggles the freeze off)
    • replace the original DOM (with all script tags) back

However that didn't work, if I hovered my mouse over the button and the modal showed up, then I invoked that algorithm with the keybind, the cloning would happen successfully and script tags would be removed, however when I remove the mouse from the button the modal would just close. As if the button was still bound to onMouseLeave.

Edit: I'm trying to do this from an external script, specifically a chrome extension.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if you have a function "myFunc" and want to malfunction it or disable it. you can clear the contents in window object.

<button onclick="freeze()">Freeze alert</button>
<button onclick="testAlert()">Test alert</button>
<script>
    function freeze() {
        window.testAlert = function testAlert() { };
    }

    function testAlert() {
        alert('The alert is active');
    }
</script>

The alert button will not work after clicking the freeze button.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda