javascript - Listening for specific DOM element insertion -


i wrote script lets me delete iframes page pressing button:

window.addeventlistener('load', function() {    var addbutton = document.createelement("button");    addbutton.innerhtml = "delete iframes";    addbutton.onclick = removealliframes;    document.body.appendchild(addbutton); });  function removealliframes() {     var iframes = document.getelementsbytagname("iframe");     (var frame of iframes) {         frame.parentnode.removechild(frame);     } } 

while works, wondering if possible listen iframe insertions , delete them appear on page. there sort of window.listentoelementinsertionbytag() method can automate this? otherwise use setinterval() , execute removealliframes() method on interval.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -