越简单越好!

一个简单的在线编辑器(JavaScript)

发表于 2006-08-24 09:30 | 337次阅读 0次点赞   JavaScript
<iframe id=x name=x height="100" style="padding:0px;"></iframe><br>
<input type=button onclick=t('UnderLine') value="下划线">
<input type=button onclick=t('bold') value="粗体">

<input type=button onclick=t('JustifyLeft') value="左对齐">
<input type=button onclick=t('JustifyCenter') value="居中对齐">
<input type=button onclick=t('JustifyRight') value="右对齐">

<input type=button onclick=t2() value="增高">
<input type=button onclick=t3() value="减少">
<script>
window.frames["x"].document.designMode="On"
//setTimeout('window.frames["x"].document.designMode="On"',200)
function t(s)
{
window.frames["x"].focus();
o=window.frames["x"].document.selection.createRange();
window.frames["x"].document.execCommand(s);
}

function t2()
{
  var obj=window.frames["x"].frameElement;
  var height = parseInt(obj.offsetHeight);
  if (height+100>=100){
  obj.height=height+100;
  }
}
function t3()
{
  var obj=window.frames["x"].frameElement;
  var height = parseInt(obj.offsetHeight);
  if (height-100>=100){
  obj.height=height-100;
  }
}
</script> 

返回顶部 ^