Well, I'm pretty sure you can, except my code is failing now.
What I'm telling my short little Javascript program to do is, pick a code from an array (I have the test one, 0, preset in, for now), and use that code to get the Youtube thumbnail for that video code, to make a semi-automatic Youtube gallery, meaning I don't have to go in, and do all the tedious work manually, just go to the video and copy the code into the array, but, when I try to change the src of the image to the url (variable) through document.getelementblahblah.src=myVar,
I get the console error: Uncaught TypeError: Cannot set property 'src' of null
Here is my code:
<!Doctype HTML>
<html>
<head>
<script>
var thumbPrefix = "http://img.youtube.com/vi/";
var thumbSuffix = "/mqdefault.jpg";
var vidCode = ['fL01KMMi5_M','6akcfoJ05Aw','lPpot4OCnQs'];
var thumb1Url = thumbPrefix + vidCode[0] + thumbSuffix;
document.write(thumb1Url); //this is just to visualize url
document.getElementById('pie').src=thumb1Url;
</script>
</head>
<body>
<img src="" id="pie" />
</body>
</html>
And, I've also tried the setAttribute method, so...