Reputation: 4539
I have a form where a user enters a video id from Vimeo and there page then previews the video in an iframe.
How do I check if the video was found?
The JS for loading the iframe is:
$(document).on('change', '#video', function(event) {
removeErrorHighlight('#video');
if (this.value == '') {
$('#vimeo_preview').empty();
} else {
if (! $('#vimeo_preview').is(':empty')) {
$('#vimeo_preview').empty();
}
$('#vimeo_preview').append('<iframe id="iframeVimeo" src="https://player.vimeo.com/video/' + this.value + '" width="100%" height="300" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
}
});
I have tried multiple ways to read the content of the iFrame but Chrome keeps blocking the "cross domain" iframe access.
Upvotes: 0
Views: 944
Reputation: 286
You won't be able to tell if the video itself loads if it is from a different domain. This is due to the same origin policy.
Upvotes: 2