让FCKeditor支持中文——解决“Error loading "/fckeditor/fckstyles.xml" ”

如果大家看到如图1那样的提示信息的话,说明你的网站名用了中文了。原来以为,asp.net 2.0应该是对中文支持得很好了,结果却是没有那么乐观。项目的名称(网站名称)如果是中文,那么fckeditor就出现了一个xml无法加载的问题:“Error loading "/fckeditor/fckstyles.xml" ”。(见图1-图3)

让FCKeditor支持中文——解决“Error loading /fckeditor/fckstyles.xml ” - Toffy - 仰望星空~~~
图1

让FCKeditor支持中文——解决“Error loading /fckeditor/fckstyles.xml ” - Toffy - 仰望星空~~~
图2

让FCKeditor支持中文——解决“Error loading /fckeditor/fckstyles.xml ” - Toffy - 仰望星空~~~
图3

例如我这个项目叫做订菜系统,那么,在VS里面运行的时候,就是http://localhost:1690/订菜系统/abc.aspx这样。

fckeditor会在 fckeditor\editor\js\fckeditorcode_ie.js 这个脚本里面,根据浏览器地址,生成“FCKConfig.BasePath”,然后再把FCKConfig.BasePath截去一部分,生成FCKConfig.EditorPath,也就是下面这行代码:

var FCKConfig=FCK.Config={};
if (document.location.protocol=='file:')
{
    FCKConfig.BasePath=decodeURIComponent(document.location.pathname.substr(1));
    FCKConfig.BasePath=FCKConfig.BasePath.replace(/\\/gi, '/');
    var sFullProtocol=document.location.href.match(/^(file\:\/{2,3})/)[1];
    if (FCKBrowserInfo.IsOpera) 
        sFullProtocol+='localhost/';
    FCKConfig.BasePath=sFullProtocol+FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1);
}else FCKConfig.BasePath=document.location.protocol+'//'+document.location.host+document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1);
FCKConfig.FullBasePath=FCKConfig.BasePath;
FCKConfig.EditorPath=FCKConfig.BasePath.replace(/editor\/$/,'');

 

其中倒数第一行:“FCKConfig.EditorPath=FCKConfig.BasePath.replace(/editor\/$/,'');”就是生成了“FCKConfig.EditorPath”。

在“fckconfig.js”文件里加载“fckstyles.xml”这个文件,就要使用到这个“FCKConfig.EditorPath”,代码如下:

FCKConfig.StylesXmlPath  = FCKConfig.EditorPath + 'fckstyles.xml' ;

 

经过我在IE6下测试,不管是使用“http://localhost:1690/订菜系统/”的方式(原文);还是使用“http://localhost:1690/%e8%ae%a2%e8%8f%9c%e7%b3%bb%e7%bb%9f/”的方式(转换),都会报错。而且我在“fckconfig.js”中加了一行代码做测试:window.status = FCKConfig.EditorPath,IE状态栏始终显示的是“http://localhost:1690/订菜系统/”。

最后的解决办法是:对“FCKConfig.EditorPath”编码,即encodeURI(FCKConfig.EditorPath) 。我顺便把下面那个xml加载也加了编码,代码如下: (以下两行在fckconfig.js文件里大概160行的地方)

FCKConfig.StylesXmlPath  = encodeURI(FCKConfig.EditorPath) + 'fckstyles.xml' ;

FCKConfig.TemplatesXmlPath = encodeURI(FCKConfig.EditorPath) + 'fcktemplates.xml' ;

目前为止,问题算是解决了。如果其它的地方还有类似的错误,也可以直接修改这里:“FCKConfig.EditorPath=FCKConfig.BasePath.replace(/editor\/$/,'');”
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值