<!DOCTYPE html>
<html>
<head>
    <title>粘贴内容</title>
    <script>
        function pasteText() {
            navigator.clipboard.readText()
                .then(function(text) {
                    var targetElement = document.getElementById('targetElement');
                    targetElement.value = text;
                    console.log('已成功粘贴文本:', text);
                })
                .catch(function(err) {
                    console.error('无法粘贴文本:', err);
                });
        }
    </script>
</head>
<body>
    <input type="text" id="targetElement">
    <button onclick="pasteText()">粘贴文本</button>
</body>
</html>