且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iframe加载网站时显示加载gif?

更新时间:2023-12-05 17:07:52

您可以在加载页面之前显示加载图像,并在加载图像时隐藏它完成(使用第二个参数添加在请求完成时调用的回调):

You can display the loading image before loading the page, and hide it when done (use the second parameter for adding a callback which is called when the request has completed):

$("#loading").show();
$("#content").load("inc/content.php", function () {
    $("#loading").hide();
});

显然,您需要文档中的元素 loading ,例如:

Obviously, you need an element in your document with the ID loading, like:

<img id="loading" src="loading.gif" alt="Loading">