Uncaught TypeError: Cannot set property 'onclick' of null

edited 五月 2016 in Javascript
請教各位:
方式一就正常播放
方式二則顯示Uncaught TypeError: Cannot set property 'onclick' of null,請問原因為何
謝謝
<!DOCTYPE html>
<html>
<head>
<title>無標題文件</title>
<script>
//方式一
/*		window.onload = function () {
			document.getElementById("paly").onclick=function() {
				
					document.getElementById("video").play();
				}
			
			}*/
//方式二
	window.onload=function() {
		var play=document.getElementById("play");
		var video=document.getElementById("video");
		play.onclick=function() {
			video.play();	
		}
	}
</script>
</head>
<body>
	<video controls=controls  poster="../upload/fwcase/20131225170653f_envmap.jpg" id="video">
    	<source src="t.mp4"></source>
        <source src"b.web"></source>
    </video>
    <input type="button" value="播放" id="paly"  />
</body>

</html>


評論

Sign In or Register to comment.