如何在后台加载图片?

编程入门 行业动态 更新时间:2024-10-25 06:31:10
本文介绍了如何在后台加载图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

问题:我正在创建一个相册。所以每次按下

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); }

更多推荐

如何在后台加载图片?

本文发布于:2023-11-27 10:16:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637663.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后台   加载   如何在   图片

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!