在线编辑器基础知识大杂烩

类别:Asp 点击:0 评论:0 推荐:

designMode应用:
使一个子框架可编辑:(on可编辑,off取消编辑,注:designMode初始默认值是Inherit,而非off)
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">

function test()
{
  var targetdoc=document.frames(0).document;
  if(targetdoc.designMode=="Off")
  {
    targetdoc.designMode="On";
  }
  else
  {
    targetdoc.designMode="Off";   
  }
}
</script>
</HEAD>
<BODY>
<INPUT type="button" value="Button" id=button1 name=button1 onclick="test()">
<iframe src="C.htm" style="border:black thin;width:200px;height:200px"></iframe>
</BODY>
</HTML>
------------------------------------
使span可编辑:

<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
function test()
{
  if(myspan.isContentEditable==true)
  {
    myspan.contentEditable=false;
  }
  else
  {
    myspan.contentEditable=true;
  }
}
</script>
</HEAD>
<BODY>
<INPUT type="button" value="Button" id=button1 name=button1 onclick="test()">
<span contenteditable id=myspan style="border:1px solid black;width:200px;height:200px"></span>
</BODY>
</HTML>
-----------------------------------------
粗体、斜体、下划线
<Button id=btnBold onclick="document.execCommand('Bold');"><b>粗体</b></Button>
<Button id=btnItalic onclick="document.execCommand('Italic');"><I>斜体</I></Button>
<Button id=btnBold onclick="document.execCommand('Underline');"><u>下划线</u></Button>

本文地址:http://com.8s8s.com/it/it8149.htm