Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get Copied Text JavaScript

const bodyEle = document.querySelector('body') // Change this 'Body' with any Tag, Class or ID
bodyEle.addEventListener('copy', function(e){
	const selection = document.getSelection() // Catch the Selection
    const selToStr = selection.toString() // Convert Selection to String
    console.log(selToStr) // Display Copied Text
})
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Get #Copied #Text #JavaScript
ADD COMMENT
Topic
Name
9+2 =