pupunzi/jquery.mb.YTPlayer — pull request #46 by danielsum (2014-08-10 12:05:46+00:00)
Title: Prevent Iframe access error

I have this error when the script is embedded in iframe (ie. in a Facebook App or loaded from another subdomain) :

Uncaught SecurityError: Blocked a frame with origin "http://xxxx" from accessing a frame with origin "http://localhost". Protocols, domains, and ports must match. @line jquery.mb.YTPlayer.js:153

I put quickly this to fix it :

try{
var canGoFullscreen = !(jQuery.browser.msie || jQuery.browser.opera || self.location.href != top.location.href);
} catch(Exception){
var canGoFullscreen = false;
}

So now the script works even if loaded from an iframe or another domain or in a Facebook apps. I don't know what will be your strategy for this (if you want also to check jQuery.browser.msie or if we have access to the top.location.href) => so I propose the safer way with a try method and if any error => canGoFullscreen = false.