Can js realize the pasting function?

Is there a way to achieve the function of

not copying but pasting?

for example, copy text in a txt file on the desktop and paste it out in a web page

May.11,2022

should be OK. Js has document.write method, input tag can be changed with js, value can be imitated and pasted, and ordinary tag can be changed innerText


third party library: clipboard.js
Native method: document.execCommand ()


of course. The idea is what @ villain jiu said. As for examples, please take a look at

_tpo_


TPO54 Writing Integrated Writing
and you can find that the js implementation is a code example.

the approximate code is as follows:

html:
<div class="wright js_textarea">
    <div class="btns">
        <a id="writearea-copy">copy</a>
        <a id="writearea-cut">cut</a>
        <a id="writearea-paste">paste</a>
        <span>Word Count:<i id="writearea-wc">0</i></span>
    </div>
    <textarea name="writing_content" id="writearea"></textarea>
</div>


js:
//
        var $write = $(config.write.SELECT_NAME);

        //
        $(".cssMasklayer").on("click", function() {
            $(this).removeClass("show");
            $(".cssNewPop").addClass("hide");
        });
        $(".cssBtnClose").on("click", function() {
            $(".cssNewPop").addClass("hide");
            $(".cssMasklayer").removeClass("show");
        });
        $(".cssReturn").on("click", function() {
            $(".cssNewPop").addClass("hide");
            $(".cssMasklayer").removeClass("show");
        });
        $(".jsIknow").on("click", function() {
            $(".cssNewPop").addClass("hide");
            $(".cssMasklayer").removeClass("show");
        });

        if ($write.length > 0) {
            var wrID = "writearea";

            //

            if (typeof window.writeAreaDefaultContent === "undefined") {
                window.writeAreaDefaultContent = "";
            }

            var writeHTML = '<div class="btns"><a id="[0]-copy">copy</a><a id="[0]-cut">cut</a><a id="[0]-paste">paste</a><span>Word Count:<i id="[0]-wc">0</i></span></div><textarea name="writing_content"  id="[0]" >' + window.writeAreaDefaultContent + "</textarea>";
            $write.html(writeHTML.replace(new RegExp("\\[0\\]", "g"), wrID));

            var domE = document.querySelector("-sharp" + wrID);
            var copy = document.querySelector("-sharp" + wrID + "-copy");
            var cut = document.querySelector("-sharp" + wrID + "-cut");
            var paste = document.querySelector("-sharp" + wrID + "-paste");
            var wcount = document.querySelector("-sharp" + wrID + "-wc");

            var saveSelStr = "";
            var temSelStr = "";
            var selStart = -1;
            var selEnd = -1;
            domE.addEventListener("keyup", function(e) {
                $(wcount).html(domE.value.replace(/\s+/g, " ").split(/[a-zA-Z]+/g).length - 1);
                canNext(getAnswer("write", $(domE)));
            });

            document.addEventListener("mouseup", function(e) {
                if (e.target.id == wrID) {
                    temSelStr = getSelectionText(e.target);
                    selStart = e.target.selectionStart;
                    selEnd = e.target.selectionEnd;
                }
            });

            copy.addEventListener("click", function() {
                saveSelStr = temSelStr;
                selStart = -1;
                selEnd = -1;
                temSelStr = "";
            });
            cut.addEventListener("click", function() {
                if (selStart != -1 && selStart != -1) {
                    saveSelStr = temSelStr;
                    var tmStr = domE.value;

                    domE.value = tmStr.substr(0, selStart) + tmStr.substr(selEnd, domE.value.length);
                    selStart = -1;
                    selEnd = -1;
                    temSelStr = "";
                } else {
                    alert("");
                }
            });
            paste.addEventListener("click", function() {
                if (selStart != -1 && selStart != -1 && saveSelStr != "") {
                    var tmStr = domE.value;
                    domE.value = tmStr.substr(0, selStart) + saveSelStr + tmStr.substr(selEnd, domE.value.length);
                } else {
                    alert("");
                }
            });
        } // end

I also want to achieve this function. Have you realized it, please?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e95c-2c419.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e95c-2c419.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?