在這裏,我與另一個問題,這一次關於YouTube的API。 我使用這個代碼來獲得一個YouTube播放器:Youtube不安全的JavaScript嘗試訪問框架與URL
<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 從框架與URL 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"> </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>
*請不要介意\」,它是在PHP中呈現,所以它只是爲逃避* - 向我們展示PHP的**輸出** – Quentin 2012-08-10 13:05:50
是的,它很煩人,我沒有其他的解釋,但是youtube正在嘗試跨源窗口訪問漏洞,以防使用允許它們的瀏覽器。在任何帶有YouTube嵌入式視頻的頁面上...... – Esailija 2012-08-10 13:08:10
Quentin,我爲您添加了輸出 – SheperdOfFire 2012-08-10 14:05:34