问题:我正在创建一个相册。所以每次按下
Problem: I am creating an album.So on every press of
时间下一步按钮我正在加载新图像。我想要实现的是,只有在从服务器完全下载新图像后,我才想从旧图像切换到新图像。
time "NEXT" button I am loading new Images. What I want to achieve is, I want to switch from old image to new image only once the new images has been downloaded fully from server.
实际上我不想在加载时显示部分图像。 有什么解决方案吗?
Actually I dont want to show partial images while loading. Is there any solution?
PS 类似问题,但这适用于Iphone。我需要浏览器?
PS SIMILAR QUESTION but this is for Iphone. I need for browser?
推荐答案只需通过javascript创建一个新图像,并且只显示 onload 已经解雇了。这将确保您看不到图像的任何部分渲染。
Just make a new image via javascript, and only show the image after the onload has fired. This will make sure you don't see any partial rendering of the image.
现场演示
Live Demo
var curImg = new Image(); curImg.src = "url to your image"; curImg.onload = function(){ // do whatever here, add it to the background, append the image ect. imgHolder.appendChild(curImg); }更多推荐
如何在后台加载图片?
发布评论