0

有没有办法使用 Jquery 附加加载 gif,任何时候我的网站上某个 div 内的任何图像正在加载?我希望它成为一个全局函数,我似乎认为这样做的唯一方法是使用 jquery 调用某个链接,然后加载,loading.gif但这在我的情况下不起作用......</p>

索引 HTML:

<div id="content">
  <div class="projectThumb">
  <img src="/img/aeffect_button_static.gif" name="aeffect" />
  <p class="title">title</p>
  </div>
</div>
<div id="popupContainer"></div>

称为 HTML:

<div class="projectPopup" id="aeffect">
  <a class="close">Close &times;</a>
  <img src="/img/aeffect_popup.jpg" width="500" height="729" alt="" />

  <p class="description">Description</p>
</div>

查询:

$(document).ready(function() {
    //Find & Open
    $(".projectThumb").click(function(){
            $("#backgroundPopup").show();
            htmlName = $(this).find("img").attr("name");
            $("#popupContainer").load("/content/" + htmlName + ".html", null, function(){
            //Set Variables
            var container = $(".projectPopup")
            var popupWidth = container.find("img:first").width()+10;
            var popupHeight = container.find("img:first").height()+60;
            var windowWidth = document.documentElement.clientWidth;
            var windowHeight = document.documentElement.clientHeight;

            //Set popup dimensions
            container.css("width" , popupWidth);
            container.css("height" , popupHeight);

            //Set popup CSS
            container.css({"position": "absolute", "background": "#000", "top": "5%", "left": (windowWidth / 2) - (popupWidth / 2) + "px", "z-index": "2" });
            });
});
    //Close property
    $("a.close").live("click", function(){
            $("#popupContainer").empty();
            $("#backgroundPopup").hide();
    });
});

提前致谢

4

1 回答 1

0

您可以连接beforeSend属性以附加处理程序以显示加载指示器。您可以在此处获得更多信息。

于 2009-09-11T15:51:56.140 回答