关闭IFRAME GETTING ERROR - 阻止具有原点的帧访问跨源帧 [英] Closing the IFRAME GETTING ERROR - blocked a frame with origin from accessing a cross-origin frame
问题描述
hi
我需要点击取消关闭IFrame。
我在表单上有取消按钮并在iFrame中打开此表单但是当我试图关闭iframe然后我收到错误
阻止一个原始框架来访问一个跨原始框架
未捕获的安全错误:使用原点 来访问具有原点http:// localhost:55557的框架a> [ ^ ]。
协议,域和端口必须匹配
这是由于同源安全策略
关闭iframe需要遵循的方法
我的尝试:
iframe查看
-------------------------------------------- -----------------------------------
@ {
ViewBag.Title =测试;
}
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";
}
在这里做我在链接和呼叫上调用onlick事件OpenIframemehtod!
Do it here i am calling onlick event on link and calling "OpenIframe" mehtod!
测试
< script type =text / javascript>
函数OpenIframe(){
if(!$('#iframe')。length){
$('#iframeHolder')。html('< iframe id =iframesrc =http:// localhost:55557 / Home / Indexwidth =700height =450 >< / iframe>');
}
返回true;
}
< /脚本>
iframe行动
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
{
//
// GET: /Home/
public ActionResult Test()
{
return View();
}
}
------------- ------------------------------------------------- < br $>
我的表格在iframe开幕
@model MyView.Models.Home
@ {
ViewBag.Title =Index;
}
索引
@using(Html.BeginForm) (null,null,FormMethod.Post,new {id =signupform})){
}
@section脚本{
@ Scripts.Render(〜/ bundles / jqueryval)
}
< script>
function 测试(){
< u> window.parent。$('#iframe')。remove();
}
< /脚本>
我的行动方式表格
--------------------------------------------------------------
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();
}
推荐答案
('#iframe')。length){
('#iframe').length) {
>
('#iframeHolder')。html('< iframe id =iframesrc =http:// localhost:55557 / Home / Indexwidth =700height =450>< ; / iframe>');
}
返回true;
}
< / script>
iframe行动
('#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
{
//
// GET: /Home/
public ActionResult Test()
{
return View();
}
}
------------- ------------------------------------------------- < br $>
我的表格在iframe开幕
@model MyView.Models.Home
@ {
ViewBag.Title =Index;
}
索引
@using(Html.BeginForm) (null,null,FormMethod.Post,new {id =signupform})){
}
@section脚本{
@ Scripts.Render(〜/ bundles / jqueryval)
}
< script>
function 测试(){
< u> window.parent。
--------------------------------------------------------------
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>
我的行动方式表格< br $> b $ b
('#iframe').remove();
}
</script>
My action Method for form
public ActionResult Index()
{
return View();
}
这篇关于关闭IFRAME GETTING ERROR - 阻止具有原点的帧访问跨源帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!