kooyee ‘s blog

开源软件, 众人努力的结晶, 全人类的共同财富
posts - 103, comments - 55, trackbacks - 0, articles - 66
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

[WEB] 在线编辑器核心技术代码

Posted on 2007-11-30 18:22 kooyee 阅读(264) 评论(0)  编辑  收藏 所属分类: Web Design网页设计
 1<iframe id=x name=x height="100" style="padding:0px;"></iframe><br>
 2<input type=button onclick=t('UnderLine') value="下划线">
 3<input type=button onclick=t('bold') value="粗体">
 4
 5<input type=button onclick=t('JustifyLeft') value="左对齐">
 6<input type=button onclick=t('JustifyCenter') value="居中对齐">
 7<input type=button onclick=t('JustifyRight') value="右对齐">
 8
 9<input type=button onclick=t2() value="增高">
10<input type=button onclick=t3() value="减少">
11<script>
12window.frames["x"].document.designMode="On"
13//setTimeout('window.frames["x"].document.designMode="On"',200)
14function t(s)
15{
16window.frames["x"].focus();
17o=window.frames["x"].document.selection.createRange();
18window.frames["x"].document.execCommand(s);
19}

20
21function t2()
22{
23  var obj=window.frames["x"].frameElement;
24  var height = parseInt(obj.offsetHeight);
25  if (height+100>=100){
26  obj.height=height+100;
27  }

28}

29function t3()
30{
31  var obj=window.frames["x"].frameElement;
32  var height = parseInt(obj.offsetHeight);
33  if (height-100>=100){
34  obj.height=height-100;
35  }

36}

37</script>

只有注册用户登录后才能发表评论。


网站导航: