【发布时间】:2011-04-30 21:49:26
【问题描述】:
解决方案:以下问题是由覆盖核心 javascript 函数的 Divx javascript 引起的。感谢 aeno 发现了这一点,并为这样做的 Divx 编码员感到羞耻!
问题:点击 tinymce 工具栏中的插入图片按钮在 IE8 中没有任何反应。
描述:请耐心等待。我不认为问题出在 tinymce 上,它可能是 IE8 的错,但我需要比我更聪明的人帮助我解决最后的难题,以确定谁对此负责...
所以基本上我在 Visual Studio 2010 中使用 tinyMCE,但我遇到了上述问题。所以我切换到 tinyMCE 源代码来调试它。问题似乎发生在 inlinepopups/editor_plugin_src.js 中的这段代码中,第 358 行:
_addAll : function(te, ne) {
var i, n, t = this, dom = tinymce.DOM;
if (is(ne, 'string'))
te.appendChild(dom.doc.createTextNode(ne));
else if (ne.length) {
te = te.appendChild(dom.create(ne[0], ne[1]));
for (i=2; i<ne.length; i++)
t._addAll(te, ne[i]);
}
},
确切的代码行是,
te = te.appendChild(dom.create(ne[0], ne[1]));
在 IE8 中,te 变为 null,因为 te.appendChild 不返回任何内容。
为了提供一些代码背景知识,te 是一个 DOM.doc.body 对象,ne 似乎是一个 json 对象,其中包含需要创建的内联弹出对象的结构。
所以回到代码.. 这适用于所有其他浏览器没问题。因此,我进入了函数 appendChild,然后我被带到了一些“JScript - 脚本块 [动态]”文件,该文件执行了不可想象的操作。它覆盖了 doc.body.appendChild 函数......你可以在下面看到它,
code cut out
...
var appendChildOriginal = doc.body.appendChild;
doc.body.appendChild = function(element)
{
appendChildOriginal(element);
var tag = element.tagName.toLowerCase();
if ("video" == tag)
{
ProcessVideoElement(element);
}
}
...
code cut out
在这里我们可以清楚地看到出了什么问题。当然 te.appendChild 什么都不返回...它没有返回声明!
所以这个难题的最后一块是这个动态脚本块吗?看在上帝的份上,我无法弄清楚这个脚本块的来源(VS2010 没有帮助)。我最深的怀疑是这是内置的 IE8?任何人都可以对此有所了解吗?下面我将提供更多这个神秘的脚本块,以防任何人都能弄清楚它来自哪里。我现在可以向你保证,它不属于我们项目中的任何脚本,因为我们已经进行了搜索,但一无所获。
var doc;
var objectTag = "embed";
// detect browser type here
var isInternetExplorer = (-1 != navigator.userAgent.indexOf("MSIE"));
var isMozillaFirefox = (-1 != navigator.userAgent.indexOf("Firefox"));
var isGoogleChrome = (-1 != navigator.userAgent.indexOf("Chrome"));
var isAppleSafari = (-1 != navigator.userAgent.indexOf("Safari"));
// universal cross-browser loader
if (isInternetExplorer)
{
// use <object> tag for Internet Explorer
objectTag = "object";
// just execute script
ReplaceVideoElements();
}
else if (isMozillaFirefox)
{
// listen for the 'DOMContentLoaded' event and then execute script
function OnDOMContentLoadedHandled(e)
{
ReplaceVideoElements();
}
window.addEventListener("DOMContentLoaded", OnDOMContentLoadedHandled, false);
}
else if (isGoogleChrome)
{
// just execute script
ReplaceVideoElements();
}
else if (isAppleSafari)
{
// listen for the 'DOMContentLoaded' event and then execute script
function OnDOMContentLoadedHandled(e)
{
ReplaceVideoElements();
}
window.addEventListener("DOMContentLoaded", OnDOMContentLoadedHandled, false);
}
function MessageHandler(event)
{
//window.addEventListener("load", OnLoad, false);
}
// replacing script
function ReplaceVideoElements()
{
if (isMozillaFirefox)
{
doc = window.content.document;
}
else
{
doc = document;
}
// set up DOM events for Google Chrome & Mozilla Firefox
if (isMozillaFirefox || isGoogleChrome || isAppleSafari)
{
doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
doc.addEventListener("DOMNodeInsertedIntoDocument", onDOMNodeInsertedIntoDocument, false);
}
// HACK : override appendChild, replaceChild, insertBefore for IE, since it doesn't support DOM events
if (isInternetExplorer)
{
var appendChildOriginal = doc.body.appendChild;
doc.body.appendChild = function(element)
{
appendChildOriginal(element);
var tag = element.tagName.toLowerCase();
if ("video" == tag)
{
ProcessVideoElement(element);
}
}
var replaceChildOriginal = doc.body.replaceChild;
doc.body.replaceChild = function(element, reference)
{
replaceChildOriginal(element, reference);
var tag = element.tagName.toLowerCase();
if ("video" == tag)
{
ProcessVideoElement(element);
}
}
var insertBeforeOriginal = doc.body.insertBefore;
doc.body.insertBefore = function(element, reference)
{
insertBeforeOriginal(element, reference);
var tag = element.tagName.toLowerCase();
if ("video" == tag)
{
ProcessVideoElement(element);
}
}
}
...
code cut out
【问题讨论】:
-
如果使用新的 tinymce 生产版本发生这种情况,您应该编写错误报告 (tinymce.moxiecode.com/develop/bugtracker_bugs.php)
标签: javascript .net image tinymce