2009-08-03 74 views
0

我在Firefox中遇到了fckeditor问题。当用户转到页面时,html(编码)存储在隐藏的输入元素中。我调用预定义的fckeditor javascript事件来使用来自隐藏的ContentBody元素的HTML填充我的编辑器。Firefox中隐藏的输入元素

 function FCKeditor_OnComplete(editorInstance) 
     { 
      editorInstance.InsertHtml(""); 
      var sample = document.getElementById("ContentBody").value; 
      editorInstance.InsertHtml(sample); 
     } 

这会在IE中自动填充所需文本的编辑器,但在Firefox中不会。萤火虫给我的错误:

A为空[该误差打破]变种 FCKW3CRange =函数(A){this._Docume ... eateFromRange(this._Document,这一点);}}; \ r \ n

使用Firebug我可以确定事件方法FCKeditor_OnComplete()只是在使用Firefox时未被触发。但是,在IE中。有关如何使这两种浏览器都能正常工作的想法?

为ContentBody的HTML是: <input type="hidden" name="ContentBody" id="ContentBody" value="<%=Model.Article%>" />

+0

请编写HTML代码 “ContentBody” – 2009-08-03 21:09:03

+0

请参见上面。感谢您的帮助! – splatto 2009-08-03 21:21:15

回答

0

我来解决这个上个月在一个新的项目时。首先,我的HTML编码字符串保存在一个隐藏的输入元素:

<input type="hidden" name="ContentBody" id="ContentBody" value="<%=Model.Body%>" /> 

此功能的情况下被调用时,在完成加载FCKeditor的实例。

function FCKeditor_OnComplete(editorInstance) 
{ 
    var oEditor = FCKeditorAPI.GetInstance(editorInstance.Name); 
    var content = parent.document.getElementById("ContentBody").value; 
    var EditedContent = content.replace(/\u201C/g, '"'); 
    oEditor.InsertHtml(EditedContent); 
    content = null; 
} 

看来火狐需要的JavaScript调用parent.document.getElementById()

0

你确定你的标签有属性ID = “ContentBody”?可以使用属性name =“ContentBody”,IE将(在技术上不正确)将其解释为getElementById的ID属性。只有你正确使用了id,Firefox才会找到它。

0

如果你打破了错误并走上堆栈,为什么A没有设置?或者,打破

document.getElementById("ContentBody").value

,并走在堆栈,寻找一个更具体的原因。

1

这很有趣。我从来没有使用FCKeditorOnComplete(我不得不删除下划线来使WMD快乐),但它看起来像一个很好的钩子。您是否尝试在下面的FCKEditor函数中设置一个断点?你使用Firefox到达那里吗?也许这是事做在您FCKeditorOnComplete物理位于...

function WaitForActive(editorInstance, newStatus) 
267...{ 
268 if (newStatus == FCK_STATUS_ACTIVE) 
269 ...{ 
270  if (FCKBrowserInfo.IsGecko) 
271   FCKTools.RunFunction(window.onresize) ; 
272 
273  _AttachFormSubmitToAPI() ; 
274 
275  FCK.SetStatus(FCK_STATUS_COMPLETE) ; 
276 
277  // Call the special "FCKeditor_OnComplete" function that should be present in 
278  // the HTML page where the editor is located. 
279  if (typeof(window.parent.FCKeditor_OnComplete) == 'function') 
280   window.parent.FCKeditor_OnComplete(FCK) ; 
281 } 
282}