Release Iframe after response.rediect part 2

2019-09-18 02:14发布

问题:

I've messed up my main question so I here I go again.

I have a mainrecord.html that uses iframe to display 2 html - top and lower. On the top html page I have a save button. This save button does some data work and then goes to a different html. The problem is the lower iframe is still there. Here is what I have in the mainrecord.html:

<iframe scrolling="no" noresize target="middle" src="<%=JustPath(oProp.ScriptPath)+[/top.html?id=]+tmpid"%> name="top" height="62%" class="auto-style1" style="width: 100%">You need a Frames Capable browser to view this content.</iframe> 
<iframe scrolling="no" noresize target="middle" src="<%=JustPath(oProp.ScriptPath)+[/lower.html?id=]+tmpid"%>  name="lower" style="width: 100%; height: 35%">You need a Frames Capable browser to view this content.</iframe> 
<script type = "text/javascript" >
element = document.getElementById("lower");
</script>

In the top.html there is a save button that goes to a saverecord.html. I do some data work and then I do this:

<script type="text/javascript">

document.removeChild(element);

</script>
<%   oResponse.Redirect(JUSTPATH(oProp.ScriptPath)+[/viewrecords.html])%>

It correctly displays viewrecords.html. However, the iframe containing lower.html is still there.

Any suggestions?

TIA.

回答1:

You need to refer to a wrapping element in your JS to remove this Iframe.

<div class="frame2">
<iframe scrolling="no" noresize target="middle" src=""..."  name="lower" style="width: 100%; height: 35%">You need a Frames Capable browser to view this content.</iframe>
</div>

JS

element = document.getElementById("frame2"); <-- this is the wrapper for your Iframe
document.removeChild(element);


标签: html iframe