从页面中删除iframe [英] Removing iframe from page

查看:2668
本文介绍了从页面中删除iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为提交表单动态创建一个iframe,在提交后我需要删除页面上的iframe表单。我删除了以下内容但未将其删除,

I am creating an iframe dynamically for submmiting a form,after submitting i need to remove the iframe form the page.I removed itas follows but it is not removed,

function remove(){
 var frame = document.getElementById("upload_iframe"),
 var frameDoc = frame.contentDocument || frame.contentWindow.document;
 frameDoc.removeChild(frameDoc.documentElement);
}

如何完全删除表单中的ifarme。

How to remove the ifarme form the form completely.

谢谢

推荐答案

框架有2个行为:框架作为文档元素(如div或其他DOM)元素)和框架作为窗口元素(如全局窗口对象)。因此,如果你想从DOM树中删除iframe,你必须使用与DOM元素一样的iframe

Frame has 2 behaviors: frame as document element (like div or another DOM element) and frame as window element (like global window object). So if you want to remove iframe from DOM tree you have to work with iframe like with DOM element

function remove(){
 var frame = document.getElementById("upload_iframe");
 frame.parentNode.removeChild(frame);
}

这篇关于从页面中删除iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆