想通过按钮控制FCK文本编辑器文本框长度,但如果想在FCK编辑器里边改的话太复杂,简直不可能,其实在调用FCK的页面改的话就容易很多了!
FCK解析出来是个iframe 在查看源文件就可以找到它的ID, 这样我们在调用FCK的页面就可以随心所欲的控制其文本框的长度了
代码如下:
<script language="javascript" type="text/javascript">
function resizeEditor(change, flag) {
var newheight = 0, newwidth=0; var obj= document.getElementById('FCKContent___Frame');
if (flag == "1") {//增加高度
newheight = parseInt(obj.style.height) + change;
if (newheight <= 900) obj.style.height = newheight + 'px';
}
else if (flag == "2") {//减小高度
newheight = parseInt(obj.style.height) - change;
if (newheight >= 500) obj.style.height = newheight + 'px';
}
else if (flag == "3") { //增加宽度
newwidth = parseInt(obj.style.width) + change;
if (newwidth <= 800) obj.style.width = newwidth + 'px';
}
else if (flag == "4") {//减小宽度
newwidth = parseInt(obj.style.width) - change;
if (newwidth >= 600) obj.style.width = newwidth + 'px';
}
return false;
}
</script>
<a href="javascript:void(0)" οnclick="return resizeEditor(100,1);">增加高度</a>
<a href="javascript:void(0)" οnclick="return resizeEditor(100,2);">减小高度</a>
<a href="javascript:void(0)" οnclick="return resizeEditor(100,3);">增加宽度</a>
<a href="javascript:void(0)" οnclick="return resizeEditor(100,4);">减小宽度</a>