现在的位置: 首页 > 综合 > 正文

Discuz和jQuery冲突的解决办法

2013年08月14日 ⁄ 综合 ⁄ 共 340字 ⁄ 字号 评论关闭

冲突一、Array.prototype.push函数冲突

Discuz 7.0版本为了兼容低版本的IE,重写了Array的push方法,代码位于include/common.js中,如下:

1
2
3
4
Array.prototype.push
=
function(value)
{
   this[this.length]
= value;
   returnthis.length;
}

但以上代码没有做任何检测直接进行了覆盖导致冲突,解决办法是修改为如下代码:

1
2
3
4
5
6
if(typeofArray.prototype.push
===
'undefined')
{
   Array.prototype.push
=
function(value)
{
      this[this.length]
= value;

抱歉!评论已关闭.