簡體   English   中英

IE發布到HTA中的iframe會打開一個新窗口

[英]IE post to iframe in HTA opens a new window

關於此主題的文章很多,但大多數是因為IE不會動態設置屬性name

我遇到了另一個麻煩:我發布了一個以iframetarget的表單(動態創建)。 第一次效果很好。 然后我第二次這樣做,並且IE打開了一個新窗口,其中包含表單提交的結果。 我非常確定這與安全性問題有關,因為:如果我創建一個簡單的HTML file (而不是HTA ),則效果很好。 另外,如果我運行在本地不可用的同一文件( http://local.host/test.hta ),則效果很好。

關於發生了什么的任何線索或如何解決? 遺憾的是它的舊代碼,我無法避免使用HTAiframes和表單提交。

這里是簡單的代碼:

<!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與主窗口之間的所有互動均被阻止。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM