Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div contenteditable></div>
  <div class='placeholder'>paste HTML here <br><br>Go to some website and select things with your mouse and copy-paste it here</div>
</body>
</html>
 
function onPaste(e){
  var content;
  e.preventDefault();
  
 
  if( e.originalEvent.clipboardData ){
    content = (e.originalEvent || e).clipboardData.getData('text/plain');
    console.log( typeof content )
    document.execCommand('insertText', false, content);
    return false;
  }
  else if( window.clipboardData ){
    content = window.clipboardData.getData('Text');
    if (window.getSelection)
      window.getSelection().getRangeAt(0).insertNode( document.createTextNode(content) );
  }
}
/////// EVENT BINDING /////////
// jQuery delegated event listener
$(document).on('paste', '[contenteditable]', onPaste);
// on-element event listener
// document.body.addEventListener("paste", onPaste);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers