views:

42

answers:

3

Im trying to create a script that will grab the users clipboard data on pageload, and show up in a textbox where they can press Submit.

Ive looked all over google and can not find the solution. I was wondering if this is possible?

A: 

Afaik it's not possible for security reasons - imagine the case that you just copy-and-pasted some password and a website steals it.

thejh
ah didn't really assume something like this when asking :PI guess I have to make the users Ctrl + V themselves >:D
Joseph
A: 

No can do. As previously mentioned, this would be a security nightmare if it was possible!

Joseph Redfern
What is the point of reiterating something just said?
Petah
A: 

Reading the clipboard is disabled by default in most browsers (for security reasons). You could try this (jQuery) but it wont work unless the user has clipboard access enabled.

<script type="text/javascript">
$(document).ready(function() {
    if(typeof(window.clipboardData)=="undefined") {
      alert("clipboard disabled")
    }
    else {
      $('#text_area").val(window.clipboardData.getData());
    }
});
<script>
Petah