Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.23 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  <script type="text/javascript">
  5.        var editorDoc;
  6.        function InitEditable () {
  7.            var editor = document.getElementById ("editor");
  8.            editorDoc = editor.contentWindow.document;          
  9.            var editorBody = editorDoc.body;
  10.            if ('spellcheck' in editorBody) {
  11.                editorBody.spellcheck = false;
  12.            }
  13.            if ('contentEditable' in editorBody) {
  14.                editorBody.contentEditable = true;
  15.            }
  16.            else {
  17.                if ('designMode' in editorDoc) {
  18.                    editorDoc.designMode = "on";                
  19.                }
  20.            }
  21.        }
  22.        function ToggleBold () {
  23.            editorDoc.execCommand ('bold', false, null);
  24.        }
  25.  </script>
  26.  <title></title>
  27. </head>
  28. <body onload="InitEditable ();">
  29.  First, write and select some text in the editor.<br>
  30.  <iframe id="editor" name="editor" src="editable.htm"></iframe><br>
  31.  <br>
  32.  You can toggle the bold/normal state of the selected text with this button:<br>
  33.  <button onclick="ToggleBold ();">Bold</button>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement