我能够使用appendChild创建一个iframe,没有jquery,我是否可以知道iframe何时加载然后能够销毁该元素?
您可以使用该onLoad活动.
<iframe onload="this.parentNode.removeChild(this);" src="/"></iframe>
Run Code Online (Sandbox Code Playgroud)
示例:http://jsfiddle.net/mSZ4X/1/
或者使用纯JavaScript:
var iframe = document.createElement("iframe");
iframe.src = "/";
iframe.onload = function() {
this.parentNode.removeChild(this);
};
document.body.appendChild(iframe);
Run Code Online (Sandbox Code Playgroud)
示例:http://jsfiddle.net/mSZ4X/2/
| 归档时间: |
|
| 查看次数: |
8117 次 |
| 最近记录: |