HTML5秘籍
最新书摘:
-
Luke2014-11-25lineCap可以设置线条两端的形状,即线头类型。默认值是butt,即方头。另外,还可以使用round(圆头)或square。每次调用stroke(),都会把画布上原有的线段再重新绘制一遍。
-
Luke2014-11-25在调用stroke()方法把直线实际绘制出来之前,可以设置context的三个属性:lineWidth, strokeStyle 和 lineCap。
-
Luke2014-11-13如果你在IE中要花大量时间测试包含JavaScript的页面,还应该在<head>区块中包含一行特殊的注释,叫做Web标志(mark of the Web);这行注释要放在指定字符编码的元数据后面,如下所示:
-
Luke2014-11-13既然HTML5是一门活语言,那为什么还要求网页中有这个所谓的文档类型声明呢?如果没有文档类型声明,那大多数浏览器将转换到一种混杂模式(quirk mode)。在这种模式下,浏览器会尝试根据有点不那么正常的规则呈现网页。而在添加文档类型声明后,浏览器就知道你想要使用更严格的标准模式(standard mode),在这种模式下,所有现代浏览器都会以一致的格式和布局来显示网页。
-
宅到死2013-04-08The problem is that the CSS heightand width properties aren’t the same as the canvas heightand width properties. If you make this mistake, what actuallyhappens is that the canvas gets its default size (300 ×150 pixels). Then, the CSS size properties stretch or squashthe canvas to fit, causing it to resize its contents accordingly.As a result, when you put an image on the canvas, it’ssquashed too, which is decidedly unappealing.
-
宅到死2013-04-06window.onpopstate是popstate事件在window对象上的事件句柄.每当处于激活状态的历史记录条目发生变化时,popstate事件就会在对应window对象上触发. 如果当前处于激活状态的历史记录条目是由history.pushState()方法创建,或者由history.replaceState()方法修改过的, 则popstate事件对象的state属性包含了这个历史记录条目的state对象的一个拷贝.调用history.pushState()或者history.replaceState()不会触发popstate事件. popstate事件只会在其他浏览器操作时触发, 比如点击后退按钮(或者在JavaScript中调用history.back()方法).当网页加载时,各浏览器对popstate事件是否触发有不同的表现,Chrome 和 Safari会触发popstate事件, 而Firefox不会.