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

117
Views
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 answers
Answer question

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 Report
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!