前端图片处理
# JS预加载图片
function preloader() {
if (document.images) {
var img1 = new Image()
var img2 = new Image()
var img3 = new Image()
img1.src = 'http://image1.gif'
img2.src = 'http://image2.gif'
img3.src = 'http://image3.gif'
}
}
function addLoadEvent(func) {
var oldonload = window.onload
if (typeof window.onload != 'function') {
window.onload = func
} else {
window.onload = function() {
if (oldonload) {
oldonload()
}
func()
}
}
}
addLoadEvent(preloader)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
上次更新: 2023/04/05, 09:41:10