Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error loading youtube video in modal dialog with chrome

I created a modal dialog to play youtube videos in. When the user clicks on a thumbnail image of the video it opens the dialog and injects the youtube iframe with this line of jQuery:

videoModal.html("<iframe class='youtube-player' id='youtube-player' type='text/html' width='640' height='385' src='http://www.youtube.com/embed/" + videoId + "?autoplay=1'  frameborder='0'></iframe>");

I get the following error only in Chrome, all other browsers do not complain

Unsafe JavaScript attempt to access frame with URL http://myDomain/ from frame with URL http://www.youtube.com/embed/MyVideoID?autoplay=1. Domains, protocols and ports must match.

Any ideas? Should I be worried about this? Any help or advice is appreciated.

like image 925
Alex Avatar asked Apr 27 '11 15:04

Alex


1 Answers

Assuming the player works, and this is a JavaScript warning in the console, I wouldn't worry about it. It just means that some script inside the iframe (at youtube) is attempting to access its parent window, which happens to be on a different domain. Cross-domain security prevents this from working, but it shouldn't affect your page.

like image 188
glomad Avatar answered Sep 28 '22 07:09

glomad