Youtube不安全JavaScript尝试使用URL访问框架

时间:2012-08-10 13:04:22

标签: javascript youtube youtube-api youtube-javascript-api

此处我还有另一个问题,这次是关于youtube API的问题。 我正在使用此代码来获取youtube播放器:

<div id=\"youtubeVideoContainer\"></div><script type=\"text/javascript\">
                        //Load player api asynchronously.
                        var tag = document.createElement('script');
                        tag.src = \"//www.youtube.com/player_api\";
                        var firstScriptTag = document.getElementsByTagName('script')[0];
                        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

                        var player;
                        function onYouTubePlayerAPIReady() {
                            player = new YT.Player('youtubeVideoContainer', {
                              height        : \"".$height."\",
                              width         : \"".$width."\",
                              videoId       : \"".$id."\",
                              playerVars    : ".json_encode($this->playerParams)."
                            });
                        }
                    </script>

请不要介意\“,它是用PHP呈现的,所以它只是用于转义,视频也在播放,所以没有重大错误:)

令我烦恼的是,每当我请求视频时,我都会在控制台中看到此消息: 不安全的JavaScript尝试使用URL

访问框架
  

https://www.socialthisday.com/playwin/admin/content/edit/project_1/home.html   来自带框架的框架   https://www.youtube.com/embed/2UJH9dCtp7w?autohide=1&autoplay=1&controls=0&border&cc_load_policy=0&color&color1&color2&disablekb&enablejsapi=1&egm&fs&hd&iv_load_policy&loop&modestbranding=1&origin=https%3A%2F%2Fwww.socialthisday.com&playerapiid&playlist&rel=0&showinfo=0&showsearch&start&theme&version=3。   域,协议和端口必须匹配。

我想解决这个问题,所以我没有看到这个消息。我知道这不是一件很重要的事情,但我现在想要如何在没有看到上述警告的情况下在我的网站上获得youtube播放器。

希望你们能帮助我!

编辑: 这是输出:

<div id="YTcontainer_502513c7ebc1b">&nbsp;</div>
                        <script type="text/javascript">
                            //Load player api asynchronously.
                            var tag = document.createElement('script');
                            tag.src = "//www.youtube.com/iframe_api";
                            var firstScriptTag = document.getElementsByTagName('script')[0];
                            firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

                            var YTplayer_502513c7eb834;                                                        
                            window.onYouTubeIframeAPIReady = function() {
                                YTplayer_502513c7eb834   = new YT.Player("YTcontainer_502513c7ebc1b", {
                                  height        : "200",
                                  width         : "200",
                                  videoId       : "2UJH9dCtp7w",
                                  playerVars    : {"autohide":1,"autoplay":1,"controls":0,"border":"","cc_load_policy":0,"color":"","color1":"","color2":"","disablekb":"","enablejsapi":"","egm":"","fs":"","hd":"","iv_load_policy":"","loop":"","modestbranding":1,"origin":"","playerapiid":"","playlist":"","rel":0,"showinfo":0,"showsearch":"","start":"","theme":"","version":3,"wmode":"opaque"}
                                });
                            }

                            if(window.YT){
                                onYouTubeIframeAPIReady();
                            }
                        </script>

2 个答案:

答案 0 :(得分:5)

潜在问题是http://code.google.com/p/chromium/issues/detail?id=17325

一旦解决了问题,使用YouTube iframe嵌入的网页上的JavaScript控制台中的警告就会消失 - 对Chrome来说肯定会消失,我也相信Safari也是如此。

答案 1 :(得分:0)

选中“使用旧嵌入代码”

它会使用<object>标记来嵌入视频