A frame has 2 types of behavior: a frame as a document element (for example, a div or another DOM element) and a frame as a window element (for example, a global window object). Therefore, if you want to remove the iframe from the DOM tree, you need to work with the iframe as a DOM element
function remove(){ var frame = document.getElementById("upload_iframe"); frame.parentNode.removeChild(frame); }
source share