简体   繁体   English

Nivo Slider在IE8中不起作用

[英]Nivo Slider not working in IE8

I am encountering some issues with the jquery nivo slider on my companies website. 我公司网站上的jquery nivo滑块遇到一些问题。

First of all, the website is hosted by an company who provided a inhouse cms where we can't change anything. 首先,该网站由一家公司托管,该公司提供了我们无法更改任何内容的内部cms。 That's why I don't have any permissons to load anything in the Head-Tag and can't upload any files except Images on that server 这就是为什么我没有任何权限可以在Head-Tag中加载任何内容,并且除了该服务器上的Images以外不能上传任何文件的原因

So I found a Javascript which loads CSS files in the head afterwards. 因此,我找到了一个Javascript,该Javascript随后会在其头部加载CSS文件。 Well all of this works properly in every browser (Chrome, FF, IE6, IE9) except IE8 the NivoSlider loads only the first Image, shows no caption, no navigation. 好了,所有这些在所有浏览器(Chrome,FF,IE6,IE9)上都能正常运行,除了IE8之外,NivoSlider仅加载第一个图像,不显示标题,也不导航。

I have no clue why it does that because if I execute the code (shown below) locally it works (all files are stored locally too). 我不知道为什么这样做,因为如果我在本地执行代码(如下所示),它将起作用(所有文件也都存储在本地)。

<script type="text/javascript" src="slider/scripts/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="slider/scripts/jquery.nivo.slider.js"></script>
<script type="text/javascript">
  function loadjscssfile(filename, filetype){
     if (filetype=="js"){ //if filename is a external JavaScript file
      var fileref=document.createElement('script')
      fileref.setAttribute("type","text/javascript")
      fileref.setAttribute("src", filename)
     }
     else if (filetype=="css"){ //if filename is an external CSS file
      var fileref=document.createElement("link")
      fileref.setAttribute("rel", "stylesheet")
      fileref.setAttribute("type", "text/css")
      fileref.setAttribute("href", filename)
     }
     if (typeof fileref!="undefined") {
      document.getElementsByTagName("head")[0].appendChild(fileref)
    }
    }

  function toggle() {
    var slider = document.getElementById("slider");
    slider.style.display = "block";
  }

    $(window).load(

    function() {
            loadjscssfile("slider/css/nivo-default.css", "css");
            loadjscssfile("slider/css/nivo-slider.css", "css");
            toggle();
            $('#slider').nivoSlider();

    }
    );

</script>

The Hoster uses Prototype JS Framework for their CMS, so I thought maybe that causes some kind interference. 托管人为其CMS使用Prototype JS Framework ,因此我认为这可能会造成某种干扰。 Actually if I open the Devtools in IE8 I shows me some errors in the Prototype.js file provided by the Hoster 实际上,如果我在IE8中打开Devtools,则会在Hoster提供的Prototype.js文件中显示一些错误。

var nodes = $(element).getElementsByTagName('*');
className = ' ' + className + ' ';

for (var i = 0, child, cn; child = nodes[i]; i++) {
  if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
      (classNames && classNames.all(function(name) {
        return !name.toString().blank() && cn.include(' ' + name + ' ');
      }))))
    elements.push(Element.extend(child));
}

It doesn't like these lines, it says something like (translated from german) "the object does not support this value or the method" 它不喜欢这些行,而是说(从德语翻译)“对象不支持该值或方法”

You can see the original homepage and code XXX and try it out for yourself. 您可以看到原始主页和代码XXX,然后自己尝试一下。 I hope you can help me with my issue. 希望您能帮我解决我的问题。

Checking with Chrome's Developer Tools, the only problem I can see is this: 使用Chrome的开发人员工具检查时,我看到的唯一问题是:

var nivo-child = $(this);

You can't have a dash in a variable name, change it to nivo_child or nivoChild . 变量名称中不能包含破折号,请将其更改为nivo_childnivoChild


To fix the second error, you need to use jQuery.noConflict() . 要解决第二个错误,您需要使用jQuery.noConflict()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM