修复ueditor百度编辑器在IE8下shCore.js报错'undefined'错误的问题
Posted on 2012-05-29 17:02 逍遥蓝枫叶 阅读(766) 评论(0) 编辑 收藏 举报ueditor在IE8下点击任意文本框报脚本错误
错误问题:
在IE8下出现脚本错误 'undefined'为空或不是对象 的问题
出现问题的文件为:
shCore.js
行数: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) 既可以修复该问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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; } }; |
原文链接: 枫叶博客:http://www.9it.me/article-9.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析