hi
I need to closed IFrame on click of from cancel.
I am Have Cancel Button on Form and opening this form in a iFrame but when i am trying to closed the Iframe then i am getting error
" Blocked a frame with origin from accessing a cross-origin frame"
Uncaught SecurityError: Blocked a frame with origin "http://localhost:55557" from accessing a frame with origin "
[
^]".
Protocols, domains, and ports must match
this due to Same-origin security policy
what approach i need to follow for closing the Iframe
What I have tried:
Iframe View
-------------------------------------------------------------------------------
@{
ViewBag.Title = "Test";
}
Do it here i am calling onlick event on link and calling "OpenIframe" mehtod!
Test
<script type="text/javascript">
function OpenIframe() {
if (!$('#iframe').length) {
$('#iframeHolder').html('<iframe id="iframe" src="http://localhost:55557/Home/Index" width="700" height="450"></iframe>');
}
return true;
}
</script>
iframe action
public class HomeController : Controller
{
public ActionResult Test()
{
return View();
}
}
--------------------------------------------------------------
My Form which is opening in Iframe
@model MyView.Models.Home
@{
ViewBag.Title = "Index";
}
Index
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "signupform" })) {
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
<script>
function Test() {
window.parent.$('#iframe').remove();
}
</script>
My action Method for form
public ActionResult Index()
{
return View();
}