<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<div class="video_bg">
<div class="video_wrap">
<video id="videot" poster="media/videoframe.png" loop autoplay muted>
<source type="video/webm" src="media/videoframe.webm">
<source type="video/mp4" src="media/videoframe.mp4">
</video>
</div>
</div>
<script>
var myVideo = document.getElementById('videot');
document.addEventListener("DOMContentLoaded", function() {
alert(String(myVideo.duration) + " seconds");
});
</script>
</body></html>
ALERT result – NAN seconds –
I upload this HTML one through the local server (Open Server)…
But when testing through Chrome DevTools, the correct result is shown…
where is the mistake ???