FCKEditor部分常用JS功能
2010-09-14 13:33:38 来源:WEB开发网// JScript 文件
//预览
function preview() {
oFCKeditor.Value=FCKeditorAPI.GetInstance('FCKeditor1').GetXHTML(true);
FCKeditorAPI.GetInstance('FCKeditor1').Preview();
}
//源代码/编辑转换
function viewsrc()
{
var obj=FCKeditorAPI.GetInstance('FCKeditor1');
oFCKeditor.Value=obj.GetXHTML(true);
obj.SwitchEditMode(FCK_EDITMODE_SOURCE);
if(obj.EditMode==FCK_EDITMODE_SOURCE)
{
document.getElementById("btn_src").value="编辑";
document.getElementById("btn_src").title="以所见即所得模块编辑";
}
else
{
document.getElementById("btn_src").value="源代码";
document.getElementById("btn_src").title="以源代码模块编辑";
}
}
//增加编辑区大小
function upsize()
{
var height=oFCKeditor.Height;
if(height<1200)
{
oFCKeditor.Height=oFCKeditor.Height+200;
document.getElementById("FCKeditor1___Frame").height=oFCKeditor.Height;
}
if(oFCKeditor.Height>1000)
document.getElementById("btn_upsize").disabled="disabled";
document.getElementById("btn_downsize").disabled="";
}
//减小编辑区大小
function downsize()
{
var height=oFCKeditor.Height;
if(height>200)
{
oFCKeditor.Height=oFCKeditor.Height-200;
document.getElementById("FCKeditor1___Frame").height=oFCKeditor.Height;
}
if(oFCKeditor.Height<400)
document.getElementById("btn_downsize").disabled="disabled";
document.getElementById("btn_upsize").disabled="";
}
//去除字符串首尾空格
String.prototype.trim = function()
{
// 用正则表达式将前后空格
// 用空字符串替代。
return this.replace(/(^s*)|(s*$)/g, "");
}
//重置编辑器(清空)
function resetFCKEditor()
{
FCKeditorAPI.GetInstance('FCKeditor1').SetHTML("");
}
//插入HTML代码到当前位置
function inserthtml()
{
var htmlstr=document.getElementById("insertstr").value;
if(htmlstr.length>2)
{
FCKeditorAPI.GetInstance('FCKeditor1').InsertHtml(htmlstr);
}
document.getElementById("insertstr").value="";
}
更多精彩
赞助商链接