Skip to content

Instantly share code, notes, and snippets.

@aneury1
Created August 9, 2019 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aneury1/1f468c3725d725b00a0ad77a22d14da7 to your computer and use it in GitHub Desktop.
Save aneury1/1f468c3725d725b00a0ad77a22d14da7 to your computer and use it in GitHub Desktop.
<div class="rich_text_area">
<iframe class="cl" id="editor" name="editor" frameborder="2" ></iframe>
</div>
...
<script src="script.js"></script>
<script>
window.onload=()=>{
const editor = document.getElementById('editor');
const doc = editor.contentDocument;
console.log(doc);
console.log(editor);
doc.designMode = "on";
editor.contentDocument.designMode = "on";
document.getElementById('boldBtn').addEventListener('click', ()=>{
doc.execCommand("Bold", false,null);
})
document.getElementById('ItalicBtn').addEventListener('click', ()=>{
doc.execCommand("Italic", false,null);
})
document.getElementById('html').addEventListener('click', ()=>{
//doc.execCommand("Italic", false,null);
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment