我在 Codeigniter 2.1.3 中使用 TinyMCE (v3.5.8) 和集成的 iBrowser 插件 (v1.4.5),我收到 JavaScript 错误 Uncaught TypeError: Cannot set property 'isMSIE' of null
请帮我解决这个问题。
谢谢。
编辑
错误在 iBrowser 插件中。
我没有对下载的文件进行任何更改。
iBrowser 插件文件夹中的 editor_plugin.js 发生错误。
iBrowser 插件网址:http://seoroot.com/blog/computing/programming/tinymce-ibrowser-plugin.html
editor_plugin.js 包含以下代码。
ib = null;
(function() {
tinymce.create('tinymce.plugins.IBrowserPlugin', {
init : function(ed, url) {
// load common script
tinymce.ScriptLoader.load(url + '/interface/common.js');
// Register commands
ed.addCommand('mceIBrowser', function() {
var e = ed.selection.getNode();
// Internal image object like a flash placeholder
if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1) {return}
ib.isMSIE = tinymce.isIE;
ib.isGecko = tinymce.isGecko;
ib.isWebKit= tinymce.isWebKit;
ib.oEditor = ed;
ib.editor = ed;
ib.selectedElement = e;
ib.baseURL = url + '/ibrowser.php';
iBrowser_open();
});
// Register buttons
ed.addButton('ibrowser', {
title : 'iBrowser',
cmd : 'mceIBrowser',
image: url + '/interface/images/tinyMCE/ibrowser.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('ibrowser', n.nodeName == 'IMG');
});
},
getInfo : function() {
return {
longname : 'iBrowser',
author : 'net4visions.com',
authorurl : 'http://net4visions.com',
infourl : 'http://net4visions.com/ibrowser.html',
version : '1.4.0'
};
}
});
// Register plugin
tinymce.PluginManager.add('ibrowser', tinymce.plugins.IBrowserPlugin);
})();
对不起。这是一个很长的代码。
注意:TinyMCE 运行良好,但该插件存在一些错误。
最佳答案
罪魁祸首是第一行代码:
ib = null;
null
不能作为对象访问。如您所见,这将引发 TypeError
。我认为解决方法是将此行更改为:
ib = {};
这样它就是一个对象并且可以设置其 isMSIE
属性。
但是,我有点不解为什么它被显式设置为 null
。我会尝试更改那行代码,看看是否会破坏某些东西,因为可能有一个原因让 ib
最初为 null。
关于javascript - TinyMCE 编辑器 : Uncaught TypeError: Cannot set property 'isMSIE' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14907029/