Created
August 15, 2018 03:47
-
-
Save saigowthamr/c22604abf0f1045102050ee1b568bc76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const first = document.querySelector(".first"); | |
const iframe = document.querySelector("iframe"); | |
const btn = document.querySelector("button"); | |
btn.addEventListener("click", () => { | |
var html = first.textContent; | |
iframe.src = "data:text/html;charset=utf-8," + encodeURI(html); | |
}); | |
first.addEventListener('keyup',()=>{ | |
var html = first.textContent; | |
iframe.src = "data:text/html;charset=utf-8," + encodeURI(html); | |
}) | |
first.addEventListener("paste", function(e) { | |
e.preventDefault(); | |
var text = e.clipboardData.getData("text/plain"); | |
document.execCommand("insertText", false, text); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment