ie8 js未指明的错误_修复ueditor百度编辑器在IE8下shCore.js报错'undefined'错误的问题...

ueditor在IE8下点击任意文本框报脚本错误

错误问题:

在IE8下出现脚本错误 'undefined' 为空或不是对象 的问题

出现问题的文件为:

行数:299行

文件路径:ueditor\third-party\SyntaxHighlighter\shCore.js

报错的代码为:

299行

real.replace.call(str.toString().slice(match.index), r2, function () {

for (var i = 1; i < arguments.length - 2; i++) {

if (arguments[i] === undefined)

match[i] = undefined;

}

});

错误原因为:299行中的

str.toString().slice(match.index)

传递进来的str变量未经过判断

在函数开始处增加

if(str!==undefined) 既可以修复该问题

RegExp.prototype.exec = function (str) {

if(str!==undefined){

var match = real.exec.apply(this, arguments),

name, r2;

if (match) {

// Fix browsers whose `exec` methods don't consistently return `undefined` for

// nonparticipating capturing groups

if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {

r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));

// Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed

// matching due to characters outside the match

real.replace.call(str.toString().slice(match.index), r2, function () {

for (var i = 1; i < arguments.length - 2; i++) {

if (arguments[i] === undefined)

match[i] = undefined;

}

});

}

// Attach named capture properties

if (this._xregexp && this._xregexp.captureNames) {

for (var i = 1; i < match.length; i++) {

name = this._xregexp.captureNames[i - 1];

if (name)

match[name] = match[i];

}

}

// Fix browsers that increment `lastIndex` after zero-length matches

if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))

this.lastIndex--;

}

return match;

}

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值