Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textarea Paste clipboard text button 2

Status
Not open for further replies.

timesign

Programmer
May 7, 2002
53
US
What is the Javascript required for a button that pastes the text of the clipboard to the form's textarea.
In other words I don't want users to have to use ctrl-v only but they should also have a "paste clipboard" button.
Thanks a load

 
In IE it's document.execCommand("PASTE") after the element has focus. Not sure about NS.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Alternatively you can also use the clipboardData object, it might have compatibility with netscape. Here's an example:
Code:
<html>
<head>
<title>Blah</title>
<script language=JavaScript>
function cb() {
   blahForm.blahTextarea.value = window.clipboardData.getData("Text");
}
</script>
</head>
<body>
<form name=blahForm>
<input type=button value='Click Me' onclick='cb()'>
<br>
<textarea name=blahTextarea></textarea>
</form>
</body>
</html>

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top