JS achieve a simple copy and paste function

Text box can not use disabled

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>复制粘贴</title>
</head>

<body>
    <script>
        function copyUrl2() {
            var Url2 = document.getElementById("biao1");
            Url2.select(); // 选择对象
            document.execCommand("Copy"); // browser is executed to copy the code area code region of the user-defined command user-defined 
            Alert ( " copied, and can be sticky paste. " ); // copy the contents inside 
        }
     </ Script > 

    < TextArea cols = "20 is " rows =" 10 " Readonly =" Readonly " ID =" biao1 " > copy the contents inside </ TextArea > 
    < INPUT type =" Button " the onClick =" copyUrl2 () " value =" click copy Code "  /> 
</ body > 

</html>

 

Guess you like

Origin www.cnblogs.com/shiyiaaa/p/11309229.html