简体   繁体   English

Magento上新小部件的Javascript错误

[英]Javascript Errors for A New Widget on Magento

I have just installed this new widget for our products called Nivo Slider, 我刚刚为我们的产品Nivo Slider安装了这个新的小部件,

This has been throwing an error in the windowonload and as such changed it from the default code on the download of: 这已经在windowonload中引发了一个错误,因此将其从下载以下内容的默认代码中更改了:

    <script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider();
});
</script>

to

<script type="text/javascript"> 
var windowOnload=window.onload||function(){};window.onload=function(){windowOnload();  {
    $('#slider').nivoSlider();
};}

I am now getting the error of 'null' is null or not an object Line: 150 Char: 9 我现在得到的错误是'null'为null或不是对象行:150字符:9

Any help on this as I have never really worked on javascript? 关于此的任何帮助,因为我从未真正使用过JavaScript? Website link is www.gadgetfreakz.co.uk/tom 网站链接是www.gadgetfreakz.co.uk/tom

Regards 问候

If you're going to use jQuery you'll probably need to put it into No Conflict mode so it doesn't interfere with Prototype (Magento uses it). 如果要使用jQuery,则可能需要将其置于“无冲突”模式,以免干扰原型(Magento使用它)。 Easiest thing I found is to just make a jquery-compat.js file with the line 我发现最简单的方法是使用以下命令制作一个jquery-compat.js文件

var $j=jQuery.noConflict();

And include that file. 并包含该文件。 Then you can use $j(...) where you would normally use $(...) 然后可以使用$j(...) ,而通常使用$(...)

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

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