显示加载GIF BeforeUnload of Page [英] Show a loading GIF BeforeUnload Of a Page
问题描述
我正在开发一款适用于计算机以及Ipad,Iphone,平板电脑和Android手机的应用程序。当用户从一个页面移动到另一个页面时,我有一个显示加载... gif的要求,因为这将为用户提供页面加载/卸载正在进行的信息。
I am working on a application which will work on computer as well as Ipad,Iphone,Tablets and Android phones. I have one requirement of Showing a loading... gif when user moves from one page to other because this will give user a info that page loading/unloading is in process.
所以我尝试下面提到的代码
///以下代码显示GIF而DOM尚未就绪。
So i Tried below mentioned code ///below code for showing GIF while DOM is not ready.
$(document).ready(function(){
$("#loading").hide();});
//在用户点击某个按钮进行某些服务器交互时显示GIF的代码。
//below code for showing GIF when user clicks on some button to do some Server Interaction.
$(window).bind('beforeunload',function(){
$("#loading").show();});
其中#loading是包含我的GIF代码的div的id。
现在这在PC浏览器上有很大的作用,但不适用于Ipad,Iphone和Android手机。我无法找出原因。
where #loading is id of a div which contains my GIF Code. Now this is working greatly on PC browsers but NOT on Ipad,Iphone and android phones. I am Not able to figure out why.
<div id="loading">
<img id="loading-image" src="/img/loading.gif" alt="Loading..." /></div>
此div用于加载GIF。
This div is for loading the GIF.
推荐答案
尝试 卸载 。
$(window).unload(function()
{
$('body').html('<img src="img/4.gif" alt="" />');
});
这篇关于显示加载GIF BeforeUnload of Page的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!