I am trying to change a YouTube video iframe source with jQuery, but looks like running into cross origin issue. My jquery code:
var videourl = $(.videourl).html();
$(.actualyoutube iframe).attr('src',videourl);
iframe gets new src value, but no video is displayed. Any ideas?
extended explanation:
There is a popup div with embeded youtube video
<div class=youtubepopup>
<div class=closeyoutube>X</div>
<div class=actualyoutube>
<iframe width=420 height=315 src= frameborder=0 allowfullscreen></iframe>
</div>
</div>
There is a certain td which contains a new src url. There is no other place or way to get this url except from this td.
<td class=videourl>//youtube.com/whatevervideo</td>
And there is a script that should add src on open popup and remove on closing.
var videourl = $(.videourl).html();
$(.youtubecap).click(function() {
$(.actualyoutube iframe).attr('src', videourl);
$(.youtubepopup).fadeIn('slow');
});
$(.closeyoutube).click(function() {
$(.youtubepopup).fadeOut('slow');
$(.actualyoutube iframe).removeAttr('src');
});
$(.youtubepopup).click(function() {
$(.youtubepopup).fadeOut('slow');
});
p.s. now that i laid it out, user3385530 is probably right