Created
January 12, 2016 00:49
-
-
Save front-thinking/6ce64fc119a1c685c172 to your computer and use it in GitHub Desktop.
图片预加载(代理模式)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myImage = (function (){ | |
var imgNode = document.createElement('img'); | |
document.body.appendChild(imgNode); | |
return { | |
setSrc: function(src){ | |
imgNode.src = src; | |
} | |
} | |
})(); | |
var proxyImage = (function (){ | |
var img = new Image; | |
img.onload = function (src){ | |
myImage.setSrc(src); | |
} | |
return { | |
setSrc: function (src){ | |
myImage.setSrc('file:// /C:/img/preLoading.gif'); | |
img.src = srac; | |
} | |
} | |
})(); | |
proxyImage.setSrc('http://dd.s.dd.s/real.png'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment