1
I’m in a little trouble when I’m going to change a property of any tag using Javascript or browser says:
Uncaught Typeerror: Cannot set Property 'src' of null
But I tested it on 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 I put in case the videoDATA
were not loaded.
Jsfiddle test: http://jsfiddle.net/4tmjjLzk/
– FRNathan13
No Jsfiddle error you sent.
– André Ribeiro
what would be <head> in wrap! so jsfiddle did not interpret the error!
– FRNathan13
@Nathan1302
No wrap - in <head>
, in Portuguese:Em <head>
, means that the script will be placed inside the<head>
in the fiddle :)– Guilherme Nascimento