Reputation: 475
I need help changing the height or width of this html 5 video. I am using html 5 and javascript to try to change the size of the video.
The following is my code:
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="default.css">
<script type="text/javascript">
document.getElementById("mainvideo").setAttribute(height,'400px');
alert('Hello');
</script>
</head>
<body>
<div id="header">
</div>
<div style="text-align:center;">
<video id="mainvideo">
<source src="movie.mp4" type="video/mp4" />
This is Fall Back Content
</video>
</div>
</body>
</html>
I have a css file that does not do anything but align the video to the middle of the screen. Is this a java script problem that is not changing the height of this video to 400px? or an html 5 problem. I also dont have a local video on me to display on screen if that is the problem also. Thanks to anyone that can help out
Upvotes: 0
Views: 3658
Reputation: 17344
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="default.css">
<script type="text/javascript">
window.onload=function(){
document.getElementById("mainvideo").style.height='400px';
alert('Hello');
};
</script>
</head>
<body>
<div id="header">
</div>
<div style="text-align:center;">
<video id="mainvideo">
<source src="movie.mp4" type="video/mp4" />
This is Fall Back Content
</video>
</div>
</body>
</html>
I don't think height
is an attribute anymore, it's a CSS property.
edit: Actually, It may never have been an HTML attribute. According to http://www.codehelp.co.uk/html/deprecated.html, width
used to be an attribute, but not height.
Upvotes: 2