Skip to content
Advertisement

Tag: dom

Detecting iframe removed by parent

I have a web application that is embedded in an iframe by external sites, of which we have no control over. Is there a way to detect when the iframe element has been removed from the dom of the parent, in order to perform some cleanup before it’s gone? It appears to fire a “visibilitychange” event, but I need to

Jest with vanilla JS – tesing generated elements on DOM

Searched a lot online but cant find the best way to get an element’s innerHTML and just compare it with the results that should be rendered (I’m trying to compare with string) what I’m trying is adding some whitespace and test failed so I’m guessing there is better ways Also, unable to query a specific element generated inside body, why?

Get the hierarchy of a XML element with XPath

I am trying to get the ordered list of the hierarchy of a given element in a “application/xml” response.data document that I parse using a DOM parser in Javascript. So the expression should return the list [‘Grand Parent’,’Parent’,’Target’] for each A tag that has no A children. So I will get a list of lists where the last element of

Rewrite MutationObserver() with async/await

How can I write this mutation observer code, using async/await? I want to return true after console.log(“Button is appearing…”);. Could someone show me the best way to write this code? I also need to clarify, this code is watching for a button, which appears and then disappears. And the reappears again, multiple times. So the mutationObserver, is watching for the

Javascript click event doesnt accept two same function

I want to use joinLobby(‘create’) and joinLobby(‘join’) functions in one page. But when I reload the page, joinLobby function working instantly. How can I prevent instant work? Answer Just having the functions like that runs them instantly. Try something like this:

How To identify which Div is displaying the scrollbar

My dashboard app is a single page – never longer than 100vh. In a certain place, when I click a button, some unknown container temporarily overflows and a scrollbar appears on the right side, and then one second later it disappears. During that one second, the page background jumps very noticeably. I wish to prevent this scrollbar from displaying via

use “this” in a function passed to eventListener

Hello people I was refactoring some code and couldn’t figure a way to reuse the ‘this’: a/ Code I have b/ I want to move the function to another file and export it as: and use it like: but ‘this’ is undefined.. how do I bind it? Answer Pass this as parameter to function (and also decouple from event too):

Advertisement