html页面上嵌入的iframe,如何关闭?

父页面:

<div id="dep_select" onclick="$(this).css('display', 'none')" style=" 100%; height: 100%; z-index: 1000; position:fixed; top: 0; left: 0; background:rgba(0,0,0,0.5); display: none;">
<iframe src="${ctx.contextPath}/strpubv2/dep_select.html" width="1250px" height="600px;" style="position:fixed;top:50%;left:50%;margin:-300px 0 0 -625px;z-index:1001;border: none;"></iframe>
</div>

在嵌入的iframe 页面中加上这样的JS代码即可

parent.document.getElementById("dep_select").style.display = "none";

原文地址:https://www.cnblogs.com/daijun/p/6102222.html