我想新的iFrame阿比examlpe @ http://code.google.com/apis/youtube/iframe_api_reference.html(下面的代码在这里..)Youtube iFrame Api示例 - 错误:“JSON未定义”?
万物工作prerfect在Chrome,Safari但 在Firefox 3.0和IE6报告错误 - > JSON未定义的行:13 玩家仍在工作,但JavaScript的完全崩溃。
我试图让页面顶部json2.js库(http://www.json.org/)脚本,但没有效果更好。 如何在这些旧浏览器上安排此JSON错误?
<html>
<body>
<!-- 1. The <div> tag will contain the <iframe> (and video player) -->
<div id="player"></div>
<script src="js/json2.js"></script>
<script language="javascript">
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'u1zgFlCw8Aw',
playerVars: { 'autoplay': 1, 'controls': 0, 'showinfo': 0, 'loop': 1, 'rel' : 0, 'showsearch' : 0, 'enablejsapi' : 1},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
function onPlayerStateChange(event) {
//
}
</script>
</body>
</html>
刚刚找到如何在IE6 http://stackoverflow.com/questions/1787020/json-object-in-ie6-how修复JSON这个较早的帖子 – Spider 2011-09-19 21:49:02