在使用chrome的模态对话框中加载youtube视频时出错 [英] Error loading youtube video in modal dialog with chrome

查看:236
本文介绍了在使用chrome的模态对话框中加载youtube视频时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个模式对话框来播放youtube视频。当用户点击视频的缩略图时,它会打开对话框并使用这行jQuery注入youtube iframe:

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>");

我仅在Chrome中收到以下错误,所有其他浏览器都不会抱怨

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

不安全的JavaScript尝试使用URL http:// myDomain / 从具有URL <的框架访问框架a href =http://www.youtube.com/embed/MyVideoID?autoplay=1 =noreferrer> http://www.youtube.com/embed/MyVideoID?autoplay=1 。域,协议和端口必须匹配。

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.

推荐答案

假设播放器工作,这是控制台中的JavaScript警告,我不会'担心它。它只是意味着iframe(在youtube)中的某些脚本正在尝试访问其父窗口,该窗口恰好位于不同的域中。跨域安全性可防止此操作,但不应影响您的页面。

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.

这篇关于在使用chrome的模态对话框中加载youtube视频时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆