所以基本上,我有一個彈出的代碼,使分區彈出。裏面有一個YouTube視頻播放器。一切正常,直到我關上窗戶,我仍然可以在背景中聽到音樂,這意味着視頻仍在播放。我想阻止它。 我做了一些研究,並落在YouTube的API上,但它仍然無法正常工作。彈出窗口中的Youtube視頻不會停止播放當窗口關閉
這裏是我的股利
echo "<div id='popupContact'>";
echo "<a id='popupContactClose'>x</a>";
echo "<div><h1>" .$row['title']. "</h1></div>";
echo "<p id='contactArea'>";
if($row[type] == "image")
echo "<img src='gallery/" .$row['path']. "' alt='" .$row['title']. "'/>";
else
echo "<iframe width='560' height='315' src='http://www.youtube.com/v/" .$row['path']."? enablejsapi=1&version=3&playerapiid=ytplayer' frameborder='0' allowfullscreen></iframe>";
echo "<br/><br/>" .$row['description']. "</p>";
echo "</div>";
echo "<div id='backgroundPopup'></div>";
代碼和這裏是彈出代碼:
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
//LOADING POPUP
//Click the button event!
$("#button").click(function(){
//centering with css
centerPopup();
//load popup
loadPopup();
});
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
});
//Click out event!
$("#backgroundPopup").click(function(){
disablePopup();
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
});
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("slow");
popupStatus = 0;
stop();
}
}
function onYouTubePlayerReady(playerId) {
alert("YAY");
ytplayer = document.getElementById("ytplayer");
}
function stop() {
if (ytplayer) {
ytplayer.stopVideo();
}
}
謝謝 阿糖胞苷
我沒有看到代碼的函數'loadPopup()'當點擊#鍵時調用.. – jmm 2012-08-15 21:22:14
功能loadPopup(){ \t //只加載彈出,如果它被禁用 \t如果( 。popupStatus == 0){ \t \t $( 「#backgroundPopup」)的CSS({ \t \t \t 「不透明性」: 「0.7」 \t \t}); \t \t $(「#backgroundPopup」)。fadeIn(「slow」); (「#popupContact」)。fadeIn(「slow」); \t \t popupStatus = 1; \t} } – user1049769 2012-08-16 00:33:32
您是否查看了我在以下答案中列出的文檔? – jmm 2012-08-16 01:42:15