用htc实现html编辑器

来源:互联网 发布:wamp域名配置 编辑:程序博客网 时间:2024/04/28 08:24

HTC,全称为HTML Component,提供了在网页中用脚本进行组件开发的机制。下面的代码,在页面中嵌入一个html编辑器,只需要几行代码,只因为使用了一个预先定义好的html编辑组件。html编辑组件定义在文件"htmleditor.htc"中,使用的是javascript脚本。这个组件来自于一个免费软件:书包行CuteIE(一款用浏览器形式实现的多功能、可无限扩充的个人信息助理软件),如果程序安装在D盘的话,那么这个组件文件的路径是D:/Program Files/CuteIE/System/inc/cuteie_client/1_0/htmleditor.htc。

如果要将此组件使用在自己的网站中,只需要将组件文件htmleditor.htc和图片目录images放置到自己的网站目录下,然后修改下面代码中的相关路径指向(如IMPLEMENTATION、SystemImagesPath)即可。

<?XML:NAMESPACE PREFIX=HENS />
<?IMPORT NAMESPACE=HENS IMPLEMENTATION="/inc/cuteie_client/1_0/htmleditor.htc"/>

<hens:htmleditor id="htmleditor1" SystemImagesPath="/inc/cuteie_client/1_0/images/" width=100% height=400></hens:htmleditor>

<script language=javascript>
//提取html编辑器的内容,只需要以下代码即可。
var oContent=htmleditor1.content;
</script>

相关资源:
书包行CuteIE下载地址:http://www.cuteie.com/CuteIESetup.exe
官方网站:http://www.cuteie.com/

由于htmleditor.htc代码比较长,下面仅摘录组件的属性、事件定义部分。

<public:component tagname=htmleditor literalcontent=true>
<public:attach event=oncontentready onevent="oncontentready()" />
<public:property name="systemImagesPath" id="_hepropSystemImagesPath" GET="getSystemImagesPath" PUT="setSystemImagesPath"/>
<public:property name="content" id="_hepropContent" GET="getContent" PUT="setContent"/>
<public:property name="contentType" id="_hepropContentType" GET="getContentType" PUT="setContentType"/>
<public:event name="onblur" id="_heevtBlur"/>
</public:component>

原创粉丝点击