Guest User

Untitled

a guest
Feb 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. (function(d) {
  2. d.open();
  3. d.write('<textarea id="input" spellcheck="false" style="flex:1;height:100%;resize:none;outline:none;font:15px monospace;color:#fff;background:#111;padding:10px;"><html>\n<head></head>\n<body>\nClick here to render\n</body>\n</html></textarea>');
  4. d.write('<iframe id="iframe" style="flex:1;height:100%;"></iframe>');
  5. d.close();
  6. var s = d.body.style;
  7. s.display = 'flex';
  8. s.margin = 0;
  9. var i = d.getElementById('input');
  10. i.onkeydown = function(e) {
  11. if ((e.keyCode || e.which) != 9) {
  12. return;
  13. }
  14. e.preventDefault();
  15. var s = this.selectionStart;
  16. this.value = this.value.substring(0, s) + " " + this.value.substring(this.selectionEnd);
  17. this.selectionEnd = s + 2;
  18. };
  19. i.select();
  20. var ifr = d.getElementById('iframe');
  21. i.addEventListener('click', function() {
  22. var idoc = ifr.contentWindow.document;
  23. idoc.open();
  24. idoc.write(i.value);
  25. idoc.close();
  26. });
  27. d.title = 'Textarea';
  28. }(document));
Add Comment
Please, Sign In to add comment