标签:des style blog http color java 使用 os io
富文本编辑器,Rich Text Editor, 简称 RTE, 是一种可内嵌于浏览器,所见即所得的文本编辑器。<span style="font-weight: bold;">I love geckos.</span><span style="font-weight: bold; font-style: italic;text-decoration: underline;">Dinosaurs are big.</span>
<STRONG>I love geckos.</STRONG><STRONG><EM><U>Dinosaurs are big.</U></EM></STRONG>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<title></title>
<style type="text/css">
.editorIframe {
border: 1px solid #0000ff;
width: 100%;
height: 300px;
}
</style>
</head>
<body onload="onload()">
<div>
自定义编译器
</div>
<div>
<button onclick="doRichEditCommand('bold')" style="font-weight:bold; width: 25px">B</button>
<button onclick="doRichEditCommand('italic')" style="font-weight:bold; width: 25px">I</button>
</div>
<div>
<iframe id="editorIframe" class="editorIframe" src="editorIframe1.html"></iframe>
</div>
<script type="text/javascript">
var editorDoc = getIFrameDocument('editorIframe');
var editorEl = document.getElementById('editorIframe');
function onload() {
document.getElementById('editorIframe').contentWindow.focus();
}
function doRichEditCommand(cmd, arg) {
//这里不能使用缓存对象,editorDoc
cmd && getIFrameDocument('editorIframe').execCommand(cmd, false, arg);
document.getElementById('editorIframe').contentWindow.focus();
}
function getIFrameDocument(aID) {
return document.getElementById(aID).contentWindow.document;
//不需要使用Mozilla写法
// if contentDocument exists, W3C compliant (Mozilla)
// if (document.getElementById(aID).contentDocument) {
// return document.getElementById(aID).contentDocument;
// } else {
// // IE
// return document.frames[aID].document;
// }
}
</script>
</body>
</html>eidtorIframe.html<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<title></title>
<style type="text/css">
html,body{
margin: 2;
}
</style>
<script type="text/javascript">
function onload() {
window.document.designMode = "On";
document.body.focus();
}
</script>
</head>
<body contentEditable="true" onload="onload()">
</body>
</html>标签:des style blog http color java 使用 os io
原文地址:http://blog.csdn.net/spy19881201/article/details/38755431