Preface: JS or jquery can be implemented to copy to the Pasteboard function, and sometimes want to have a newline format (with textarea)
Demo
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><%@ taglib Prefix="C"URI="Http://java.sun.com/jsp/jstl/core"%><HTML><Head> <title>Test</title></Head><Body> <ButtonID= "BTN1">Copy custom content to Pasteboard</Button> <BR/>Box 1<textareaID= "txt"></textarea> <BR/> <ButtonID= "BTN2">Copy box 1 contents to Pasteboard</Button> <BR/>Box 2<textareaID= "Txt3"></textarea> <ButtonID= "Btn3">Copy box 1 contents to box 2, while to Pasteboard</Button> <Scripttype= "Text/javascript">window.onload= function(){ functionCopyvalue (val) {//If this is changed to input then line wrapping is not supported varTemp=Document.createelement ('textarea'); Temp.value=Val; Document.body.appendChild (temp); Temp.select (); //Select ObjectDocument.execcommand ("Copy"); //perform a browser copy commandTemp.style.display='None'; Console.log ('Replication succeeded'); } document.getElementById ("BTN1"). onclick= function() {Copyvalue ("1234\n copy succeeded \ nthe line was changed ."); }; document.getElementById ("btn2"). onclick= function() {Copyvalue (document.getElementById ("txt"). Value); }; functionCopyValue2 (val) {varOinput=document.getElementById ('Txt3'); Oinput.value=Val; Oinput.select (); //Select ObjectDocument.execcommand ("Copy"); //perform a browser copy commandConsole.log ('Replication succeeded'); } document.getElementById ("Btn3"). onclick= function() {copyValue2 (document.getElementById ("txt"). Value); }; }; </Script></Body></HTML>
Note: If you need to support line breaks, you need to use textarea
JS implementation Copy to Pasteboard function