Skip to content

Instantly share code, notes, and snippets.

@saigowthamr
Created August 15, 2018 03:47
Show Gist options
  • Save saigowthamr/c22604abf0f1045102050ee1b568bc76 to your computer and use it in GitHub Desktop.
Save saigowthamr/c22604abf0f1045102050ee1b568bc76 to your computer and use it in GitHub Desktop.
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