1

我在使用我网站上的“Stratus 2”网络播放器时遇到问题。我已经下载并将“Jquery”放入公共文件夹。它被命名为 jquery.js

然后,我在结束正文标记之前附加了以下代码。

<html class="html">
<head>

<script type="text/javascript">
   if(typeof Muse == "undefined") window.Muse = {}; window.Muse.assets = {"required":["jquery-1.8.3.min.js", "museutils.js", "jquery.scrolleffects.js", "jquery.musepolyfill.bgsize.js", "jquery.watch.js", "webpro.js", "musewpslideshow.js", "jquery.museoverlay.js", "touchswipe.js", "index.css"], "outOfDate":[]};
</script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://stratus.sc/stratus.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $.stratus({
      download: false,
      align: 'top',
      user:false,
      color:'E8C58B',
      links: 'https://soundcloud.com/man-in-a-loft-downtown/sets/the-latest'
    });
  });
</script>

我也尝试过在头部标签中输入代码。播放器不显示。有什么想法吗?

我在控制台上收到此错误

$.stratus is not a function

但我看到 stratus.js 文件确实加载了。

全头代码: http ://shrib.com/aA2V6JqX

请查看并进行相应的编辑。

4

2 回答 2

2

在你的网站上闲逛之后,我现在正在听你的音乐播放器,听起来不错!

您正在加载两个不同版本的 jQuery。

// version 1.8.3
window.Muse.assets = {"required":["jquery-1.8.3.min.js", "museutils.js", "jquery.scrolleffects.js", "jquery.musepolyfill.bgsize.js", "jquery.watch.js", "webpro.js", "musewpslideshow.js", "jquery.museoverlay.js", "touchswipe.js", "index.css"], "outOfDate":[]};

和 1.7.2

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

如果您检查生成的 HTML,您会看到 Muse 在加载您的 stratus 插件后加载 jQuery,因此会覆盖它。

一个糟糕但可行的解决方案是等到加载 Muse 的 jQuery 加载,但我不知道有一种简单的方法来检测它,所以你可以让它忙着等待。删除加载 1.7.2 的行并将初始化脚本更改为

function checkjQuery() {
    if (window.jQuery) {
      $.getScript( "http://stratus.sc/stratus.js", function() {
        $.stratus({
          download: false,
          align: 'top',
          user:false,
          color:'E8C58B',
          links: 'https://soundcloud.com/man-in-a-loft-downtown/sets/the-latest'
        });
      });
    } else {
      setTimeout(checkjQuery, 10);
    }
}
checkjQuery();
于 2014-08-14T12:59:27.883 回答
1

将您的 jQuery 版本升级到 1.7 或更高版本,并更改$('body').stratus(​​ insted$.stratus(

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script type="text/javascript" src="http://stratus.sc/stratus.js"></script>

<script type="text/javascript">
$(document).ready(function(){
$('body').stratus({
  links: 'https://soundcloud.com/iagoofficial/iago-hold-back'
 });
});
</script>
</head>
<body>
</body>
</html>
于 2014-08-14T13:05:55.173 回答