【问题标题】:jquery wait till large document is loadedjquery 等到大文件被加载
【发布时间】:2010-05-31 14:58:47
【问题描述】:

在我的 Web 应用程序中,我称文档可能很大。该文档被加载到 iframe 中。

我有一个标题、按钮和文本,它们都依赖于这个文档。文本来自大文档并显示在 iframe 中。我想在文档加载到 3 个位置(1:文档标题,2:文档按钮,3:文档文本,iframe)时显示动画 gif

我在 iframe 上尝试了 onload 事件,但这并没有给我想要的效果。

这是我加载文档的代码:

function loadDocument(id, doc) {
    $("#DocumentContent").show();
    $("#ButtonBox").show();

    // Clear dynamic menu items
    $("#DynamicMenuContent").html("");
    $("#PageContent").html("");

    // Load document in frame
    $("#iframeDocument").attr("src", 'ViewDoc.aspx?id=' + id + '&doc=' + doc + '');    

    //    $("#iframeDocument").attr("src", "Graphics/loader.gif");    

    // Load menu items
    $.ajax({
        url: "ShowButtons.aspx?id=" + id + "&doc=" + doc,
        success: function(data) { $("#DynamicMenuContent").html(data) },
        error: function(xhr, err, e) { alert("error: " + err) }
    });    

    // Set document title
    $("#documentTitle").load("GetDocumentInfo.aspx?p=title");
}

我的问题,如何在加载文档时显示加载器 gif?并在文档准备好时删除 gif?

【问题讨论】:

    标签: jquery html iframe


    【解决方案1】:

    你试过.ready() - http://api.jquery.com/ready/

    【讨论】:

      【解决方案2】:

      您可以使用 Jquery 阻止和取消阻止...

      【讨论】:

        【解决方案3】:

        我创建了一个带有图像和一些文本的 div。在我的函数中,我使这个 div 可见。我还创建了一个隐藏此 div 的 javascript 函数 (closeLoading())。在 iframe 的加载中,我调用 closeLoading()。我的灵感来自这个网站:http://mf.pastebin.com/f3c863aa4

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-02-04
          • 1970-01-01
          • 1970-01-01
          • 2018-03-09
          • 1970-01-01
          • 2023-03-21
          • 1970-01-01
          相关资源
          最近更新 更多