编辑器:
aspx页面:
<script type="text/javascript" charset="utf-8" src="./../Content/ckeditor/ckeditor.js"></script>
<style type="text/css">
.editor,.editorDiv { width: 450px; height: 60px; overflow: auto; text-align: left; border:1px solid #ccc; padding:5px; cursor:hand;}
.editorFoucs { border: 1px solid red; background: #F6F0AC;}
</style>
<div id="comment" name="评论内容" class="editor" ></div>
<div id="editorDialog" title="质量状态数据录入">
<textarea id="editor" name="editor" cols="80" rows="50"></textarea>
<div>还可输入 <span id="leaveId"></span> 字 <span id="limitId" style="display:none; color:red;">(长度超限,请控制在8000字符以内)</span></div>
<div class="text-notice" style="display:none;">友情提醒:您正在使用IE6,建议升级到IE8</div>
</div>
js:
var editor;
var currentEditorId = ""; //当前页面中所有的TextArea均在唯一的ckeditor对象中编辑,此值用于记录当前处于编辑状态的textarea的ID
var timerId = null; //定义定时器用于实时检测富文件编辑器还可输入的字数
var editorMaxLength = 7998;
$(function () {
initEditor();
});
function initEditor() {
$("#editorDialog").dialog(
{
show: "fast",
modal: true,
resizable: false,
bgiframe: false,
autoOpen: false,
width: 550,
buttons: {
"取消": function () {
$(this).dialog("close");
},
"确定": function () {
$("#" + currentEditorId).html(editor.getData());
$(this).dialog("close");
}
},
beforeclose: function (event, ui) {
if (timerId != null) {
clearTimeout(timerId);
timerId = null;
}
$("#" + currentEditorId).removeClass("editorFoucs");
if (editor) { editor.destroy(); editor = null; }
}
});
//绑定textarea的点击事件,以触发显示editor的dialog
$(".editor").bind("click", function () {
currentEditorId = $(this).attr("id");
showEditorDialog($(this).attr("name"));
});
}
aspx页面:
<script type="text/javascript" charset="utf-8" src="./../Content/ckeditor/ckeditor.js"></script>
<style type="text/css">
.editor,.editorDiv { width: 450px; height: 60px; overflow: auto; text-align: left; border:1px solid #ccc; padding:5px; cursor:hand;}
.editorFoucs { border: 1px solid red; background: #F6F0AC;}
</style>
<div id="comment" name="评论内容" class="editor" ></div>
<div id="editorDialog" title="质量状态数据录入">
<textarea id="editor" name="editor" cols="80" rows="50"></textarea>
<div>还可输入 <span id="leaveId"></span> 字 <span id="limitId" style="display:none; color:red;">(长度超限,请控制在8000字符以内)</span></div>
<div class="text-notice" style="display:none;">友情提醒:您正在使用IE6,建议升级到IE8</div>
</div>
js:
var editor;
var currentEditorId = ""; //当前页面中所有的TextArea均在唯一的ckeditor对象中编辑,此值用于记录当前处于编辑状态的textarea的ID
var timerId = null; //定义定时器用于实时检测富文件编辑器还可输入的字数
var editorMaxLength = 7998;
$(function () {
initEditor();
});
function initEditor() {
$("#editorDialog").dialog(
{
show: "fast",
modal: true,
resizable: false,
bgiframe: false,
autoOpen: false,
width: 550,
buttons: {
"取消": function () {
$(this).dialog("close");
},
"确定": function () {
$("#" + currentEditorId).html(editor.getData());
$(this).dialog("close");
}
},
beforeclose: function (event, ui) {
if (timerId != null) {
clearTimeout(timerId);
timerId = null;
}
$("#" + currentEditorId).removeClass("editorFoucs");
if (editor) { editor.destroy(); editor = null; }
}
});
//绑定textarea的点击事件,以触发显示editor的dialog
$(".editor").bind("click", function () {
currentEditorId = $(this).attr("id");
showEditorDialog($(this).attr("name"));
});
}