Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

javascript - 在页面卸载前显示加载的GIF(Show a loading GIF BeforeUnload Of a Page)

I am working on a application which will work on computer as well as Ipad,Iphone,Tablets and Android phones.(我正在开发可在计算机以及Ipad,Iphone,平板电脑和Android手机上使用的应用程序。)

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的要求,因为这将为用户提供正在加载/卸载页面的信息。) So i Tried below mentioned code ///below code for showing GIF while DOM is not ready.(所以我尝试了下面提到的代码///下面的代码,用于在DOM未准备好时显示GIF。) $(document).ready(function(){ $("#loading").hide();}); //below code for showing GIF when user clicks on some button to do some Server Interaction.(//下面的代码,用于在用户单击某些按钮进行某些服务器交互时显示GIF。) $(window).bind('beforeunload',function(){ $("#loading").show();}); where #loading is id of a div which contains my GIF Code.(其中#loading是div的ID,其中包含我的GIF代码。) Now this is working greatly on PC browsers but NOT on Ipad,Iphone and android phones.(现在,这在PC浏览器上可以很好地工作,但不适用于Ipad,Iphone和android手机。) I am Not able to figure out why.(我不知道为什么。) <div id="loading"> <img id="loading-image" src="/img/loading.gif" alt="Loading..." /></div> This div is for loading the GIF.(该div用于加载GIF。)   ask by anuj pradhan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try unload .(尝试卸载 。)

$(window).unload(function() { $('body').html('<img src="img/4.gif" alt="" />'); });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...