1
<!DOCTYPE html>
<HTML>
<HEAD>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
video {
right: 0;
bottom: 0;
min-width: 50%;
min-height: 50%;
max-width: 90%;
max-height:90%;
width: auto;
height: auto;
</style>
</HEAD>
<BODY bgcolor=black>
<center><video width="853" height="480" autoplay="autoplay">
<source src="file:///C:/Program Files/NARUTO SHIPPUDEN Ultimate Ninja STORM 2/IntroMovie.mp4" type="video/mp4" />
Your browser does not support HTML5 video.
</video></center>
</BODY>
<script type="text/javascript">
document.body.addEventListener("onclick", function(){
alert("Hello! I am an alert box!!");
});
document.body.addEventListener("oncontextmenu", function(){
alert("Hello! I am an alert box!!");
});
document.body.addEventListener("onkeypress", function(){
alert("Hello! I am an alert box!!");
});
</script>
</HTML>
由於某種原因,無論何時點擊正文(無論是在視頻內部還是在視頻之外),警報框都不會彈出。HTML/Javascript addEventListener不能調用?
是否有任何理由爲什麼代碼不顯示警告框?
這肯定解決它!感謝您及時的回覆! (當stackexchange會讓我,我將它添加爲最佳答案。) – 2015-04-02 22:12:43
@GameAnalysis你現在應該有能力,很高興我可以幫助! – 2015-04-02 22:13:43
作爲一個側面說明,按鍵不工作的原因,但keydown工作正常! – 2015-04-02 22:20:27