首页 新闻 会员 周边

有关编写html文本编辑器的遇到的问题

0
悬赏园豆:10 [已关闭问题]

最近由于要进行编辑CMS,遇到一些问题,就是html文本编辑器的问题,我们要写新闻,就一定用到它。但是网上开源的都不尽人意,所以我想根据自己需求,编写属于我自己的html文本编辑器。

 

我使用的是编写文本放在一个页面,对文本的编辑放在它的父框架中,我要对文本进行操作就要调用到内层的那个框架。

编写文本的网页  richTextEditor.htm

<iframe id="textEdit" class="BlanktextEdit"></iframe>

调用js代码:texteditor.js

window.onload=initEditor;

function initEditor()
{
    textEdit.document.designMode="On";
    textEdit.document.open();
    textEdit.document.write("");
    textEdit.document.close();  
}


function execCommand(command) {
 if (format=="HTML") {
  var edit = textEdit.document.selection.createRange();
  if (arguments[1]==null)
   edit.execCommand(command);
  else
   edit.execCommand(command,false, arguments[1]);
  edit.select();
  textEdit.focus();
 }
}

 进行编辑的页面  Editor.aspx

<table id="editbar2" cellpadding="0px" cellspacing="0px" >
<tr>
      <td title="拷贝" onclick="Copy()" ><img src="images/copy.gif" width="23" height="22"></td>
</tr>
</table>
<iframe id="edit1" src="richTextEditor.htm" name="myEditor"></iframe> 
调用js  editor.js

function Copy(){
 myEditor.focus();
 doFormat("Copy");
}

//重点在这里

function doFormat(what) {
 //myEditor.setFocus();

 //var eb = document.all.editbar2;
 myEditor.frames.textEdit.execCommand(what);
}

 

我怎么编写这段代码?

。。。。。。

 

 

 

一刀刘的主页 一刀刘 | 初学一级 | 园豆:132
提问于:2009-02-20 17:30
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册