Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39203
  • 博文数量: 26
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 275
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-20 20:38
个人简介

本人从事SEO

文章分类

全部博文(26)

文章存档

2015年(25)

2014年(1)

我的朋友

分类: 信息化

2015-04-02 11:10:03

  FCKeditor跟Wordpress使用的TinyMCE一样,都是OpenSource的WYSIWYG Editor(所见即所得编辑器),一直以来比较习惯用FCKeditor这套编辑器来帮网页加入可以编辑HTML的功能,但今天突然发现如果一个页面有 两个FCKeditor且在Firefox运行时,若要使用FCKeditorAPI.GetInstance()来取得编辑器的instance,只有 第一个可以正确取得,第二个将会是undefined,第三个以上没试但应该也难逃厄运了。


  运行环境:


  Firefox 3.0.1


  FCKeditor 2.6.3


  发生错误可能原因:


  fckeditorcode_gecko.js 有Bug


  Firefox有Bug或与FCKeditor有小部份衝突


  解决概念:


  如果是第一个原因,我实在没兴趣把压缩过的fckeditorcode_gecko.js解回来检查(压缩过都还有253K啊!),更别说Firefox有bug能帮上什麽忙了,不过幸好在FCKeditor JavaScript API有提到,可以建立一个名为FCKeditor_OnComplete 的callback function,当FCKeditor载入完毕后将会呼叫这个function并传入一个参数,这个参数就是目前装载完毕的FCKeditor Instance,只要把这个参数记录下来,就可以直接使用Instance,不需要用FCKeditorAPI.GetInstance()来取得,这 样一来便解决问题了。


  解决方式:


  在FCKeditor载入之前加入以下Javascript


  //修正FckEditor错误


  var __fckEditorInstance_  = new Array();//用来储存FCKeditor Instance的阵列


  function FCKeditor_On


  Complete( editorInstance )


  {


  __fckEditorInstance_[editorInstance.Name] = editorInstance;


  }


  function getFckInst(idname)


  {


  return __fckEditorInstance_[idname];


  }


  之后就可以利用getFckInst()来代替FCKeditorAPI.GetInstance()取得FCKeditor Instance

     文章信息来源           
阅读(1196) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~