簡體   English   中英

使用iframe的jQuery對話框在IE9中不起作用

[英]Jquery dialog with Iframe not working in IE9

IE9中未觸發iframe的jQuery對話框。

我的parent.aspx上有一個HTML按鈕

<input type="button" id="btnMessageFilter" class="mainFont" value="Message Filter"/>

在“ btnMessageFilter”上單擊,我想在Jquery對話框中打開另一個aspx頁面(child.aspx); 我這樣做是這樣的:

$(document).ready(function () {
    $("#btnMessageFilter").live('click', function () {
        var iframe = $("<iframe>").attr({
            "src": "MessageFilter.aspx?btn=btnRefresh",
            "height": "100%",
            "marginwidth": "0",
            "marginheight": "0",
            "scrolling": "auto",
            "frameborder": "0"
        });
        $("#dialog2").empty().append(iframe);
        $("#dialog2").dialog({
            modal: true,
            title: 'Message Filter',
            width: 400,
            height: 450
        });
        $("#dialog2").parent().appendTo('form');
        return false;
    });
});      

除IE9外,該代碼工作正常。 有什么建議可以修復上述鱈魚,也可以通過其他方法在Jquery對話框中打開另一個aspx?

我不確定您的代碼有什么問題。 但是我在網站的某些頁面上使用iframes + jQuery-ui對話框,如下所示:

var iframe = $('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>');
var dialog = $("<div></div>").append(iframe).appendTo("body").dialog({
    autoOpen: false, // autoopen is set to false (we'll create only one dialog and open it on-demand)
    modal: true,
    resizable: false,
    width: "auto",  // set width and
    height: "auto", // height to auto (we'll set width/height on the content)
    close: function() {
        iframe.attr("src", ""); // load blank document in iframe
                                // can be useful in situations, for example,
                                // when your frame is playing audio or video
    }
});
$('#btnMessageFilter').click(function() {
    iframe.attr("width", 400).attr("height", 200); // set width/height on the content
    dialog.dialog("option", "title", "Message Filter").dialog("open");
    iframe.attr("src", "http://example.com");
});

在這里演示

我正在回復此主題,因為我還沒有找到解決該問題的正確方法。

要解決此問題,請確保您設置了“操作結束時的iframe src”。

示例-在以上情況下,必須在.dialog()調用之后設置src。

暫無
暫無

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

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