Legacy Archive (2013): Originally written in Chinese on doubixie.com and translated into English for this edition. All archive posts · Home

Turns Out jQuery and Discuz! Actually Conflict

Original Chinese title: 原来jquery和discuz还是有冲突的

While working on a Discuz! template, I needed a banner effect and remembered I had downloaded nivo-slider earlier. Everything worked fine when embedded inside a module, but when using DIY mode, the JS failed to load properly. At first I suspected a conflict with some core functions, then I realized the widget used jQuery 1.9.0.

After googling it, I found out that jQuery’s $() clashes with common.js, making it unusable. Here’s a workaround I grabbed:

 1、打开discuz中共用的header.hrm文件,在<script type="text/javascript" src="{$jspath}common.js?{VERHASH}"></script>下面加载jQuery<script type="text/javascript" src="{$jspath}jquery.js?{VERHASH}"></script>。
2、这里两种情况,一种是直接在文档中写js代码
<script language="javascript" type="text/javascript"> 
<!--  
var jq = jQuery.noConflict();
jq(document).ready(function(){  
    jq("select").sSelect();  
})  
--> 
</script> 
这里我自定义的函数名就是jq,还有一种情况是外链一个js文件,情况是一样的,只要在这个js文件开头加上var jq = jQuery.noConflict();,然后下面用到$的地方都替换为自定义函数名jq就可以了。

Would you believe I eventually gave in and just used runslideshow(); from common.js to make a big slideshow instead?

runslideshow();

<div class="slidebox"><!--幻灯片开始-->

<div class="slideshow"> </div><!--图片展示-->

<div class="slidebar"> </div><!--幻灯片控制展示-->

</div><!--幻灯片结束-->

A very simple slideshow

[loop]
[Archived image unavailable in 2013–2019 mirror: {pic}]
[/loop]

[loop1]{currentorder}[/loop1]

<script type="text/javascript">
    runslideshow();
</script>

Slideshow speed

在<div class="slidebox" >增加参数  如下代码  其中 timestep="3000"  为毫秒 

Multiple images

<div class="slidebox"  slidenum="3" slidestep="1">
其中  slidenum="3"  表示显示数量  , slidestep="1" 表示每点击一次左右按扭 移动的次数