I made a website, which opens a popup window with this JavaScript code:
document.getElementById("i_song_name").innerHTML =
'<iframe width="100" height="100" src="https://www.youtube.com/v/FjNdYp2gXRY?autoplay=1" id="i_song_name_i"></iframe>';
This code adds an iframe
tag to the span
tag.
Then in JS, I want to get title of YouTube website with this code:
document.getElementById("h3").innerHTML =
document.getElementById("i_song_name_i")
.contentWindow.document.head
.getElementsByTagName("title")[0].innerHTML
.replace(" - YouTube", "");
So I want to have this code:
<span id="i_song_name">
<iframe width="100"
height="100"
src="https://www.youtube.com/v/FjNdYp2gXRY?autoplay=1"
id="i_song_name_i"></iframe>
</span>
<div id="h3">Ahrix - Nova [NCS Release]</div>
Unfortunately, my browser (Google Chrome), still prints an error:
SecurityError: Blocked a frame with origin "null" from accessing a cross-origin frame.
Any idea how to solve this problem?