2011-06-25 53 views
0

我有一個問題,Fancybox的YouTube視頻實現工作在我的本地主機上。當我加載頁面我得到這個錯誤:Fancybox YouTube視頻無法在本地主機上工作

Unsafe JavaScript attempt to access frame with URL http://sites:8888/clients/project_name/v1/products/index from frame with URL http://www.youtube.com/embed/RtXSVGsQ8N0 . Domains, protocols and ports must match.

我明明想確保實施工作正常之前,我把它推到直播服務器。

在此先感謝。

回答

0

似乎你要麼做一個跨域AJAX調用。你的瀏覽器是什麼?

+0

Mac上的Safari,有沒有跨域文件,我可以添加到頁面標題,可讓該本地主機上? – Torez

+1

沒有。這是出於安全原因,非常正確。所以,你最好的選擇是使用iframe的youtube代碼。 –

0

要澄清ToyDaVirus,確保指定類型參數IFRAME

即​​


$('#selector').click(function() { 

     $.fancybox({ 

     'padding'   : 10, 
     'autoScale'   : false, 
     'transitionIn'  : 'elastic', 
     'centerOnScroll' : true, 
     'overlayColor'  : '#000', 
     'transitionOut'  : 'none', 
     'title'    : this.title, 
     'width'    : 680, 
     'height'   : 495, 
     'href'    : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'), 
     'type'    : 'iframe', 

     'swf'    : { 
      'wmode'    : 'transparent', 
      'allowfullscreen' : 'true' 
     } 

     }); 

     return false; 
}); 
相關問題