Linuxなどのメモ書き

リッチテキスト編集


IE,FireFox,NN,mozillaではブラウザ上でワープロソフトのようにリッチテキスト編集を行うことができる。この機能の使い方をまとめる。

1.リッチ編集モードの有効化

ブラウザのリッチ編集モードを指定するにはdocumentのdesignModeをOnにする。

1.1 FireFox,NN,Mozillaの場合


 (iframe)designMode
 

document.getElementById(id).contentDocument.designMode = "on";
(idにはiframeのidを指定すること)


iframe
 
    <iframe id="edit" width="500px" height="400px">
      エディット用の領域
    </iframe>

1.2 IE  


designMode=On
 
frames[0].document.designMode = "On";

1.3   


使italicunderline
 

<html>
  <body onload='init();'>
    <table border=1 >
      <tr>
         <td onmousedown='doc.execCommand("italic", false,
null);'>
           Italic</td>
         <td onmousedown='doc.execCommand("underline", false,
null);'>
           Underline</td>
      </tr>
    </table>
    <script type="text/javascript">
      var doc;
      function init()
      {
        id = "edit";
        if (document.all) {
          // IE
          doc = frames[0].document;
        } else {
          doc = document.getElementById(id).contentDocument;
        }
        doc.designMode = "on";
      }
    </script>

    <iframe id="edit" width="500px"
height="400px"></iframe>
  </body>
</html>


2.execCommand  

designMode"on"()(docdesignMode"on"document)
 
doc.execCommand("underline", false, null);

"bold","underline","fontsize",...
 
(?)FireFox1.5true(NS_ERROR_NOT_IMPLEMENTED)
 
"bold"(null)"forecolor"()"rgb(0,0,255)"
 
IE 
 mozilla /  ()
 

3.  

3.1 heading  


IEIEformatblock使
 

3.2 backcolor  


IEMozillaIEMozillaMozillahilitecolor使
 

3.3 formatblock  


execCommand3IE"<h1>"<>Mozilla"h1"
 
doc.execCommand("formatblock", false, "<h1>");

3.4 forecolor  


'#RRGGBB'
 
doc.execCommand("forecolor", false, "#0000ff");

IE6<font>colorFireFox<span>style(color)
 
IE6('')FireFoxIE6<font>colorFireFoxIE6
 


4.サンプル

(1) リッチ編集モードを使用したサンプル。
http://www.bit-hive.com/~tomita/RichEditor/

(2) このWikiのデモページ編集モードはこちら


最終更新 2007/04/17 12:12:34 - kztomita
(2006/04/10 22:33:33 作成)



リンク

Wiki
Linux
Xnu


()




Web(LAMP)
Linux




draggable.js
検索

Adsense

最近のコメント