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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -