【问题标题】:How to close Iframe in c# MVC如何在 c# MVC 中关闭 iframe
【发布时间】:2017-02-07 05:59:18
【问题描述】:

我不想在 cshtml 文件中使用 target="_parent"。我想从服务器端关闭它。即在 C# 动作中重定向到新窗口。

目前它在同一个 iframe 中打开。

【问题讨论】:

    标签: c# asp.net-mvc iframe


    【解决方案1】:

    经过一番努力,我找到了解决上述问题的方法。

    在成功发布后,我已重定向到新的 View .cshtml 和 javascript。

    <script type="text/javascript">
        
        $(document).ready(function () {
    
            var IframeModal = top.window.document.getElementById('myIframeModal');
    
            if ($(QuickAddUserModal).css('display') == "block") {
                parent.iFrameClose('#IframeModal');
            }
    
            if ('@Model.GoToUserRecordOnSave'=='False') {            
                parent.window.location.reload();
            }
            else {
                var url = '@Url.Action("ViewUser", "Users", new { id = Model.Id })';
                parent.window.location.href = url;
            }
        });
    </script>

    如您所见,首先我关闭了 Iframe,然后重定向到不会在 Iframe 中打开的新窗口。这对我来说很好!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-08
      • 2010-12-10
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多