| 1 | <!DOCTYPE html> |
|---|
| 2 | <html> |
|---|
| 3 | <head> |
|---|
| 4 | <meta charset="utf-8"> |
|---|
| 5 | <title>Pastebin</title> |
|---|
| 6 | <style> |
|---|
| 7 | div { |
|---|
| 8 | padding: 20px; |
|---|
| 9 | } |
|---|
| 10 | [contenteditable=true] { |
|---|
| 11 | border: solid 2px green; |
|---|
| 12 | } |
|---|
| 13 | </style> |
|---|
| 14 | </head> |
|---|
| 15 | <body> |
|---|
| 16 | <p>Paste content here:</p> |
|---|
| 17 | <div id="pastebin" contenteditable="true"></div> |
|---|
| 18 | <p>Produced HTML:</p> |
|---|
| 19 | <textarea cols="100" rows="20" id="output"></textarea> |
|---|
| 20 | |
|---|
| 21 | <script> |
|---|
| 22 | |
|---|
| 23 | var pastebin = document.getElementById( 'pastebin' ); |
|---|
| 24 | |
|---|
| 25 | if ( pastebin.addEventListener ) |
|---|
| 26 | pastebin.addEventListener( 'paste', onPaste ); |
|---|
| 27 | else |
|---|
| 28 | pastebin.attachEvent( 'onpaste', onPaste ); |
|---|
| 29 | |
|---|
| 30 | function onPaste() { |
|---|
| 31 | setTimeout( function() { |
|---|
| 32 | document.getElementById( 'output' ).value = pastebin.innerHTML; |
|---|
| 33 | }, 100 ); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | </script> |
|---|
| 37 | </body> |
|---|
| 38 | </html> |
|---|