【问题标题】:django redirect to parent of iframe from viewdjango 从视图重定向到 iframe 的父级
【发布时间】:2012-08-24 10:39:38
【问题描述】:

我有一个通过 iframe 呈现的网页。在 iframe 中成功提交表单后,我给出了,

 return HttpResponseRedirect("www.google.com")

但目标页面也在 iframe 中加载。如何指定要从 django 视图重新加载的父级?

【问题讨论】:

    标签: python django iframe


    【解决方案1】:

    只需返回一些 html:

    redirect_template.html:

    <html>
        <head>
            <script>
                window.top.location.href = '{{ redirect_url }}';
            </script>
        </head>
        <body></body>
    </html>
    

    代替:

    return HttpResponseRedirect("www.google.com")
    

    用途:

    return TemplateResponse(request, 'redirect_template.html', {'redirect_url':'www.google.com'}
    

    【讨论】:

    • 我们是否还需要更改父&lt;iframe&gt;sandbox属性?
    猜你喜欢
    • 2019-07-03
    • 1970-01-01
    • 2011-06-05
    • 1970-01-01
    • 1970-01-01
    • 2011-01-06
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多