【问题标题】:facebook iframe apps youtube embed error unsafe javascriptfacebook iframe 应用程序 youtube 嵌入错误不安全的 javascript
【发布时间】:2011-10-14 03:08:19
【问题描述】:

我在我的 facebook iframe 应用程序中使用此嵌入代码:

<iframe width="420" height="315" src="http://www.youtube.com/embed/XXXXXX" frameborder="0" allowfullscreen></iframe>

但我在萤火虫控制台上收到此错误:

Unsafe JavaScript attempt to access frame with URL http://apps.facebook.com/xxxxxxxx/?state=f1f21e5736ae4e193f7234cae34842be&code=AQDKwOTwhCcU0DiWBuVO5igIudWEtypxt4xMNjDTN_dtK5ltdFb7e-2-EW1rWeIotL3v1RaanI390wWwkCLJH1dpFr76rCOZyKGCVCgBC40tUIaseY3FxLoXsoqLIRZ3X6zW3HgXr-YIY0dOSpPBKugxVKOT_28W-ejhQoFkbFg0iuTg-tonVJeCrRyXKg4yc9U#_=_ from frame with URL http://www.youtube.com/embed/XXXXXX. Domains, protocols and ports must match.

我在我的 html 标头上放置了 facebook 元标记:

<meta property="og:video" content="<?php echo $youtube_url;?>" />
<meta property="og:video:secure_url" content="<?php echo $youtube_url;?>" />
<meta property="og:video:height" content="640" />
<meta property="og:video:width" content="385" />
<meta property="og:video:type" content="application/x-shockwave-flash" />

但我不断收到这些错误。

关于如何在 facebook iframe 中嵌入 youtube 视频的任何线索/建议?

【问题讨论】:

    标签: javascript facebook facebook-graph-api youtube youtube-api


    【解决方案1】:

    确保您在 Youtube 网址中使用 https

    【讨论】:

      【解决方案2】:

      尽管在控制台日志中看到令人恼火,但可以放心地忽略此错误。

      这是由Same Origin Policy 引起的。 YouTube iframe 正在尝试通过 JavaScript 与父网站中的某些内容进行通信或访问,但您的浏览器拒绝访问,因为它不在同一个域中,因此不可信。

      【讨论】:

        猜你喜欢
        • 2011-11-23
        • 2012-07-27
        • 2012-11-17
        • 1970-01-01
        • 2014-10-29
        • 2015-02-27
        • 2014-01-22
        • 2013-04-08
        • 2012-08-29
        相关资源
        最近更新 更多