IE浏览器发布到HTA中的iframe会打开一个新窗口 [英] IE post to iframe in HTA opens a new window

查看:93
本文介绍了IE浏览器发布到HTA中的iframe会打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于这个话题有很多文章,但其中大部分都是因为IE没有动态设置属性 name

There are a lot of posts about this topic but most of them are because IE doesn't set the attribute name dynamically.

我遇到了不同的麻烦:我发布了一个表单(动态创建),使用 iframe 作为 target 。它第一次很好。然后,我再次执行此操作,IE会打开一个窗体,并提交表单提交的结果。我很确定它与安全问题有关,因为:如果我创建一个简单的 HTML文件(而不是 HTA 它很好。另外,如果我运行的文件不在本地工作( http://local.host/test.hta )它的效果很好。

I'm having a different trouble: I post a form (created dynamically) with an iframe as target. The first time it works great. Then I do it for a second time and IE opens a new window with the result of form's submission. I'm pretty sure it has to do with security issues because: if I create a simple HTML file (instead of a HTA) it works great. Also, if I run the same file that doesn't work locally (http://local.host/test.hta) it works great.

有什么线索可以解决它,或者我该如何解决它?令人遗憾的是它的遗留代码,我无法避免使用 HTA iframes 并表单提交。

Any clue of whats going on or how can I fix it? Sadly its legacy code and I can't avoid using HTA or iframes and form submiting.

这里是它的简单代码:

Here its the simple code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <HTA:APPLICATION 
        ID="oHTAGeneral_v5" 
        APPLICATIONNAME="TEST"
        ICON='Img/icono.ico'
        SCROLL="no"
        SINGLEINSTANCE="yes"
        SELECTION='yes'
        NAVIGABLE='yes'
        SHOWINTASKBAR='Yes'
        WINDOWSTATE='normal' />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.min.js"></script>
        <script type="text/javascript">
            $(function() {

                var url = "http://www.some-url.com/",
                    first = true;

                $("#frame").unbind("load");
                $("#frame").load(function(){

                    if (first) {
                        first = false;
                        $("#frame")[0].contentWindow.document.cookie  = "testCookie=dummyValue";
                        $("<form></form>")
                            .attr("target", "frame").attr("method", "POST").attr("action", url)
                            .css("display", "none")
                            .appendTo($(document.body))
                            .append('<input type="hidden" name="dummy" value="dummy" />')
                            .submit();
                        return;
                    }

                    // Other stuff

                });

                $("<form></form>")
                    .attr("target", "frame").attr("method", "POST").attr("action", url)
                    .css("display", "none")
                    .appendTo($(document.body))
                    .append('<input type="hidden" name="dummy" value="dummy" />')
                    .submit();
            });
        </script>
    </head>
    <body>
        <iframe id="frame" name="frame" width="200" height="50"></iframe>
    </body>
</html>


推荐答案

您可以尝试使用 iframe 标记中的application =yes属性。没有所述属性的iframe在HTA中被认为是不安全的,并且iframe和主窗口之间的所有交互都被阻止。

You can try to use application="yes" attribute within iframe tag. Iframes without the said attribute are considered as unsafe in HTA, and all interaction between iframe and main window is blocked.

这篇关于IE浏览器发布到HTA中的iframe会打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆