我有两个函数可以使用 swfobject.js 和 jquery 在 youtube 视频中加载,以从 youtube rss 中获取一些 json 数据。
这两个函数都使用非常相似的代码来嵌入带有 swfobject.js 的视频。我加载了 IE8,当弹出对话框时说:
Line: 4
Char: 5
Error: not implemented
Code: 0
如果我点击“是”,所有视频都会加载。如果我点击“否”,则只有 3 个视频中的一个会加载。我只想知道为什么其中一个会加载,而其他的不会。这里有一些 IE8 不喜欢的突兀代码吗?
如果我点击是或否,则加载的代码在这里:
function getVideo(videoID, divName){//Gets yt video for yt category posts
var videoURL = videoID;
var divID = divName+'-video';
var width = 392; //only change this number
var height = Math.floor(width*9/16);
var params = { allowScriptAccess: "always" };
var atts = { 'class': 'hmt-ytvideo' };
swfobject.embedSWF("http://www.youtube.com/v/"+videoURL+"?enablejsapi=1&playerapiid=ytplayer&version=3",
divID, width, height, "8", null, null, params, atts);
}
<script type="text/javascript">
var youtubeID = '<?php echo $urlYoutube; //pass the php var to js var?>';
var divID = '<?php echo $divName; //pass the php var to js var?>';
addLoadEvent(getVideo(youtubeID, divID));//Onload function to output video
</script>
当我点击是时加载并且在我点击否时不加载的代码在这里:
function getFirstSideVideo(){
//First sidebar video, represented by the url 'start-index' value
$j.getJSON(rssFeedURL, function(data) {
$j.each(data.feed.entry, function(i, item) {
var updated = item.updated;
var urlLink = item['link'][4]['href'];
var width = 315; //only change this number
var height = width*9/16;
//SWF object params
var videoURL = urlLink.split('/uploads/')[1];
var params = { allowScriptAccess: "always" };
var atts = { 'class': 'hmt-ytvideo' };
var divID = 'first-sidebar-video';
//Output video with swf object
swfobject.embedSWF("http://www.youtube.com/v/"+videoURL+"?enablejsapi=1&playerapiid=ytplayer&version=3",
divID, width, height, "8", null, null, params, atts);
});
});
}
<script type="text/javascript">//Onloads the function to output the video
addLoadEvent(getFirstSideVideo);
</script>