Get current clipboard content?

Gabriele Cirulli picture Gabriele Cirulli · Jun 20, 2011 · Viewed 191.6k times · Source

I'd like to know a way to make my script detect the content of the clipboard and paste it into a text field when the page is opened, with no input from the user. How can it be done?

Answer

Dave picture Dave · Jun 20, 2011

window.clipboardData.getData('Text') will work in some browsers. However, many browsers where it does work will prompt the user as to whether or not they wish the web page to have access to the clipboard.