不能添加相同的js

时间:2013-11-01 09:58:00

标签: javascript jquery html css

我希望在一个html页面上有两个这个画廊...但我不能重新复制代码。我相信我需要为此工作制作一些其他的div ...我希望有一个画廊显示我的youtube频道,另一个显示另一个youtube频道。

<html lang="en">
<head>
<link href="http://files.enjin.com/469593/Styles/ytv.css" type="text/css" rel="stylesheet" />
<link href="http://files.enjin.com/469593/Styles/main.css" type="text/css" rel="stylesheet" />
</head>
<body>

<div id="frame">
</div>

<!--Change user to your channel-->
<script>
window.onload = function(){
window.controller = new YTV('frame', {
user: 'midnightmafiaGUILD',
accent: 'yellow'
});

};
</script>

<div id="frame">
</div>

<!--Change user to your channel-->
<script>
window.onload = function(){
window.controller = new YTV('frame', {
user: 'other youtube channel',
accent: 'yellow'
});

};
</script>

<script type="text/javascript" src="http://files.enjin.com/469593/Styles/ytv.js"></script>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

首先尝试加载外部脚本。

<script type="text/javascript" src="http://files.enjin.com/469593/Styles/ytv.js"></script>

<script>
window.onload = function(){
window.controller = new YTV('frame', {
user: 'midnightmafiaGUILD',
playlist: 'PLdxzlBKS1wMV2fjkYR9GA2f3t0R4CAof8',
accent: 'yellow'
});

};
</script>

答案 1 :(得分:0)

您必须先包含youtube js,然后再使用它,

<script type="text/javascript" src="http://files.enjin.com/469593/Styles/ytv.js"></script>
<script>
    window.onload = function(){
        window.controller = new YTV('frame', {
            user: 'midnightmafiaGUILD',
            playlist: 'PLdxzlBKS1wMV2fjkYR9GA2f3t0R4CAof8',
            accent: 'yellow'
        });
    };
</script>