Ask javascript to automatically copy the specified content to the pasteboard when the page is loaded.

when you click manually, you can copy the specified content to the pasteboard, and add an automatic loading page on this basis, how to achieve it?

< hr >
<body>
    

<input type="text" id="inputText" value="444"/> <input type="button" id="btn" value=""/> <hr> <textarea rows="4"></textarea> <script type="text/javascript"> var btn = document.getElementById("btn"); btn.addEventListener("click", function(){ var inputText = document.getElementById("inputText"); var currentFocus = document.activeElement; inputText.focus(); inputText.setSelectionRange(0, inputText.value.length); document.execCommand("copy", true); currentFocus.focus(); alert(""); }); </script> <script type="text/javascript"> window.onload=function(){ var btn = document.getElementById("btn"); btn.click(); document.execCommand("copy", true); } </script> </body>
Mar.16,2021
Menu