从另一个网页+ asp.net关闭iFrame [英] Close iFrame from another webpage + asp.net
问题描述
我正在研究ASP.NET Web应用程序.我有两个网页,网页1具有iFrame,其中使用jQuery对话框在其中加载了网页2.
I am working on a ASP.NET Web application. I have two web pages, Web Page 1 has iFrame in which Web Page 2 is loaded using jQuery dialog.
从网页1单击超级链接时,iframe将加载第二个网页,在网页2上执行一些操作(将数据提交到db),在单击提交按钮提交数据后,要关闭iframe/对话框,该用户将被重定向到网页1.
From web page 1 when clicked a hyper link, iframe will be loaded with second webpage, Some operations are perfromed on webpage 2 (submitting data to db), after submitting data hitting submit button, want to close the Iframe/Dialog so that user will be redirected to Web Page 1.
如何从网页2中关闭网页1中的IFrame/对话框?
How can I close the IFrame/Dialog which is in Web Page 1 from Web Page 2 ??
这是asp.net网络表单应用程序
It's asp.net webforms application
推荐答案
我以这种方式尝试过,并且有效:
I tried in this way and it worked:
在网页1中编写了一个用于关闭/删除iframe的函数:
In webpage 1 wrote a function which closes/removed iframe:
<script type="text/JavaScript" language="JavaScript">
var removeMyIFrame = function() {
$('#MyiFrame').remove();
}
</script>
使用以下代码段从第二页调用上述功能:
called above function from secodnd page using below snippet:
ASPX:
<script type="text/JavaScript" language="JavaScript">
function CloseMe() {
parent.removeMyIFrame()
}
</script>
.CS按钮单击:
ScriptManager.RegisterStartupScript(Me.Page, Page.[GetType](), "text", "CloseMe()", True)
这篇关于从另一个网页+ asp.net关闭iFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!