I have a small problem, when I change a property of any tag using Javascript the browser says:
Uncaught TypeError: Can not set property 'src' of null
But I tested it in JSFiddle and it worked correctly with the same parameters!
Code:
function get(idOf) {
return document.getElementById(idOf);
}
function loadData(id, videoDATA) {
get(id).src = "https://www.youtube.com/embed/" + videoDATA;
}
window.onload = function () {
get('404').innerHtml = '<iframe src="" width="500px" height="400px" frameborder="0" id="frame0"></iframe>';
loadData('frame0', 'kdWAmMRmELg');
}
<div id="404">...</div>
is a DIV that I put in if videoDATA
was not loaded.