1. 没啥好说的直接贴代码,原理也在前言里面说明了,主要是用他的解码js函数
aspx页面(引用页)
<
script
type
="text/javascript"
src
="/CuteSoft_Client/CuteEditor/Scripts/Gecko_Implementation/CuteEditorImplementation.js"
></
script
>
< input type ="hidden" id ="Hidden1" value ='<%="这里改成你含Word格式的数据源"% > ' />
< script type ="text/javascript" language ="javascript" >
document.write(CuteEditor_Decode(document.getElementById( " hidvalue " ).value));
</ script >
< input type ="hidden" id ="Hidden1" value ='<%="这里改成你含Word格式的数据源"% > ' />
< script type ="text/javascript" language ="javascript" >
document.write(CuteEditor_Decode(document.getElementById( " hidvalue " ).value));
</ script >
代码解说:CuteEditor_Decode函数就是关键的解码函数了,这里没有把数据源直接放到script内部是因为文章里面可能有“'”这样的字符而出错。
结束
关于CuteEditor也是最近两天才试用,不知道用FCKeditor的朋友有没有遇到同样的问题,献丑的多说句我找的方法:先直接输出文章,找里面的替换特殊字符(应该比较明显,比如#2、#1)然后整个项目搜索这个字符串,凭经验找到可能的JS文件,把压缩过的JS用格式化工具格式一下,再找到对应出现过的字符就可以找到方法了。
补充[2008年9月17日]
在修改的时候如果直接把存在数据库带Word格式的文章赋值给CuteEditor的话格式也是出不来的,同样也需要转换,但是这里就不能像显示那样导入js文件直接调用了,会报JS错误的,所以需要单独把方法摘出来调用,替换一下格式字符就行了,这里我已经整理好了,贴给大家:
function
CuteEditor_Decode(Ox98) {
if ( ! Ox98)
{
return Ox98;
};
Ox98 = Ox98.replace( / #1 / g, " < " );
Ox98 = Ox98.replace( / #2 / g, " > " );
Ox98 = Ox98.replace( / #3 / g, " & " );
Ox98 = Ox98.replace( / #4 / g, " * " );
Ox98 = Ox98.replace( / #5 / g, " o " );
Ox98 = Ox98.replace( / #6 / g, " O " );
Ox98 = Ox98.replace( / #7 / g, " s " );
Ox98 = Ox98.replace( / #8 / g, " S " );
Ox98 = Ox98.replace( / #9 / g, " e " );
Ox98 = Ox98.replace( / #a / g, " E " );
Ox98 = Ox98.replace( / #0 / g, " # " );
return Ox98;
}
本文转自博客园农民伯伯的博客,原文链接:CuteEditor Html中显示Word格式粘贴的文章[CuteEditor WordToHtml],如需转载请自行联系原博主。if ( ! Ox98)
{
return Ox98;
};
Ox98 = Ox98.replace( / #1 / g, " < " );
Ox98 = Ox98.replace( / #2 / g, " > " );
Ox98 = Ox98.replace( / #3 / g, " & " );
Ox98 = Ox98.replace( / #4 / g, " * " );
Ox98 = Ox98.replace( / #5 / g, " o " );
Ox98 = Ox98.replace( / #6 / g, " O " );
Ox98 = Ox98.replace( / #7 / g, " s " );
Ox98 = Ox98.replace( / #8 / g, " S " );
Ox98 = Ox98.replace( / #9 / g, " e " );
Ox98 = Ox98.replace( / #a / g, " E " );
Ox98 = Ox98.replace( / #0 / g, " # " );
return Ox98;
}