4. 使用 audio 和 video
• <audio controls="controls"> <source src="song.ogg" type="audio/ogg">
<source src="song.mp3" type="audio/mpeg"> Your browser does not
support the audio tag.
</audio>
• <video width="320" height="240" controls="controls"> <source
src="movie.ogg" type="video/ogg"> <source src="movie.mp4"
type="video/mp4"> Your browser does not support the video tag.
</video>
Test:
http://www.w3school.com.cn/tiy/t.asp?
f=html5_audio_all
http://www.w3school.com.cn/tiy/t.asp?
f=html5_video_all
7. Canvas 简单示例
• <script type="text/javascript">
• function drawShape(){
– // get the canvas element using the DOM
– var canvas = document.getElementById('tutorial');
– // Make sure we don't execute when canvas isn't supported
– if (canvas.getContext){
– // use getContext to use the canvas for drawing
– var ctx = canvas.getContext('2d');
– // Draw shapes
– //left,top,width,height
– ctx.fillRect(25,25,100,100); // 绘制矩形,并以 fillStyle 填充
– ctx.clearRect(45,45,60,60); // 清除制定矩形区域
– ctx.strokeRect(50,50,50,50); // 绘制矩形,以 strokeStyle 绘制边界
• }
• }
• </script>
8. Web application -new features
1. location storge---session storge
客户端 session 和本地持久化 (亦即 DOM 存储)
2. Firefox 中的离线资源
3. web 应用程序中使用文件
( 注:除新的 DOM 存储特性外,其它目前只有 ff 支
持)
重点看下 location storge---session storge, 最新浏览器
都实现了对它的支持 ~
14. DOM new fetures
• getElementsByClassName
Document 和 元素结点对象支持 getElementsByClassName
方法。有了它,就可以通过 class 或者一组 class 来查找
元素。
• 拖拽
HTML5 的拖拽 API 支持页面内甚至跨站点拖拽对象。同时
,也为扩展和基于 Mozilla 的应用提供了一些更简单的
API 。
• HTML 的焦点管理
支持新的 activeElement 和 hasFocus 属性。
document.activeElement document.hasFocus
• 基于 web 协议的处理器
你可以用 navigator.registerProtocolHandler() 方法将 web
22. Web GL
Web 3D is coming!
Web gl = JavaScript+OpenGL ES 2.0+canvas !!!
不需要 Flash ,不需要 Silverlight !!!
OpenGL :3D 图形 API 。这些 API 是通过 HTML 5 的 canvas
标签来使用的 .
定义了一个跨编程语言 、跨平台的编程接口的规格 ,它
用于三维图象 (二维的亦可 )
从 HTML 的脚本标签中加载 Shader (渲染器 ) :
<script id="shader-fs" type="x-shader/x-fragment">