先运行一下下面的代码:
editor.html 主要是一些Javascript,用来处理不同的命令。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
New Document
<!-- var contentHTML; function exeCommand(command, value) { document.execCommand(command, false, value); } // 加粗 function Black() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('Bold', ''); } // 斜体 function Italic() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('Italic', ''); } // 下划线 function UnderLine() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('Underline', ''); } // 向里缩进 function Indent() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('Indent', ''); } // 向外缩进 function Outdent() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('Outdent', ''); } // 无序列表 function UnorderList() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('InsertUnorderedList', ''); } // 有序列表 function OrderList() { var obj = frames['ifRTC'].RTC; obj.focus(); exeCommand('InsertOrderedList', ''); } // 插入图片 function Image() { var obj = frames['ifRTC'].RTC; obj.focus(); ImagePath = window.prompt('请输入图片路径:', ''); exeCommand('InsertImage', ImagePath); } // 预览效果 function Preview() { var htmlContent = frames['ifRTC'].RTC.innerHTML; var open = window.open(''); open.document.write(htmlContent); } // 查看编辑框里的HTML源代码 function Source() { var htmlContent = frames['ifRTC'].RTC.innerHTML; if (document.all.iframeDiv.style.display == 'block') { document.all.iframeDiv.style.display = 'none'; document.all.htmlText.value = htmlContent; document.all.textDiv.style.display = 'block'; document.all.htmlText.focus(); document.all.Source.value='HTML'; } else { document.all.iframeDiv.style.display = 'block'; document.all.textDiv.style.display = 'none'; frames['ifRTC'].RTC.innerHTML = document.all.htmlText.value; frames['ifRTC'].RTC.focus(); document.all.Source.value=' 源代码 '; } } // 增加编辑框的高度 function Add() { document.all.ifRTC.height = document.all.ifRTC.height*1 + 50; } //-->
blank.html文件
我的问题是,为什么我在编辑框里面,一回车,光标就下跳两行,这是为什么,还有怎么去解决这个问题