Skip to content

Instantly share code, notes, and snippets.

@easesu
easesu / bindImageLoadEvent
Created June 24, 2014 15:13
注册图片加载事件
function bindImageLoadEvent(img, callback) {
// if loaded, directly execute callback
if (img.readyState === "complete" || img.complete) {
callback.apply(img);
return true;
}
// otherwise register event
if (img.readyState) {
img.attachEvent("onreadystatechange", function() {
if (img.readyState === "complete") {
<!DOCTYPE html> <!-- HTML5 doctype 不区分大小写 -->
<html lang="zh-cmn-Hans-CN"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用IE最新版本和 Chrome -->
<!-- width=device-width 会导致 iPhone 5 添加到主屏后以 WebAPP 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz -->
<meta name ="viewport" content ="initial-scale=1.0, maximum-scale=3, minimum-scale=1, user-scalable=no">

Template Components

Used to provide structural templates.

Pattern

t-template-name
t-template-name--modifier-name
t-template-name__subcomponent-name--subcomponent-modifier-name