复制后重新显示文本文件中的文本

So I have a textarea that grabs the text from a .txt file and a button that can copy this text.

I am having problems because I would like to replace the textarea value to "... Copied to Clipboard" for a quick second, then change it back to the text from the .txt file.

这是标头中的代码:

<?php 
$pfile = "proxies.txt";
$count = count(file($pfile));  

$proxyfile = fopen($pfile, "r") or die("Unable to open file!");
$proxyread = fread($proxyfile,filesize($pfile));
fclose($proxyfile);

$datefile = fopen("date.txt", "r") or die("Unable to open file!");
$dateread = fread($datefile,filesize("date.txt")); 
fclose($datefile);
?>

这是有问题的脚本:

<script>
function copyProxies() {

    var copyText = document.getElementById("proxies");
    copyText.select();
    copyText.setSelectionRange(0, 99999999)
    document.execCommand("copy");

    copyText.value = "[<?php echo $count ?>] Proxies Copied to Clipboard!";
    copyText.select();
    copyText.setSelectionRange(0, 99999999)

    setTimeout(function() {
        copyText.value = "<?php echo $proxyread ?>";
        copyText.select();
        copyText.setSelectionRange(0, 99999999)
    }, 750);

}
</script>

归结为这一行不起作用:

copyText.value = "<?php echo $proxyread ?>";

If I change copyText.value = "<?php echo $proxyread?>"; to -> copyText.value = "test12345"; it works perfectly fine.

When I use the echo $proxyread in-between <textarea></textarea> it also works perfectly fine. But when i am trying to use copyText.value = "<?php echo $proxyread?>"; it doesn't work...at all...

有人可以告诉我为什么复制文本后不能在文本区域上重新显示该文本吗?希望能有所帮助,谢谢!

评论