Last active
December 17, 2015 21:39
-
-
Save swainet/5676032 to your computer and use it in GitHub Desktop.
网速检测
This file contains hidden or 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
window.addEventListener('load', function () { | |
var interval = 500, begin = Date.now(), img = new Image(), timer = setTimeout(handler, interval); | |
window.removeEventListener('load', arguments.callee); | |
img.addEventListener('load', handler, false); | |
img.src = 'https://i.alipayobjects.com/e/201305/Q9jNoeIir.gif?t=' + begin; | |
function handler() { | |
clearTimeout(timer); | |
img.removeEventListener('load', handler); | |
//响应在500ms以内算高速网络 高清(HD)标清(SD) | |
document.body.className = (document.body.className + (Date.now() - begin < interval ? ' ui-hd' : ' ui-sd')).trim(); | |
} | |
}, false); |
This file contains hidden or 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
window.addEventListener("load",function(){var interval=500,begin=Date.now(),img=new Image,timer=setTimeout(handler,interval);window.removeEventListener("load",arguments.callee);img.addEventListener("load",handler,false);img.src="https://i.alipayobjects.com/e/201305/Q9jNoeIir.gif?t="+begin;function handler(){clearTimeout(timer);img.removeEventListener("load",handler);document.body.className=(document.body.className+(Date.now()-begin<interval?" ui-hd":" ui-sd")).trim()}},false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请将图片移动到用户本地不缓存的 user-nocache 目录,并移除随机参数。
例如: