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
Post a Comment