复制网页网址的PHP代码

2024-10-20 08:38:30      61 浏览    作者:li52
<?php
$currentUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
?>
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Copy URL</title>
    <script>
        function copyUrl() {
            const url = '<?php echo $currentUrl; ?>';
            navigator.clipboard.writeText(url).then(function() {
                console.log('URL copied to clipboard');
            }).catch(function(error) {
                console.error('Failed to copy the URL: ', error);
            });
        }
    </script>
</head>
<body>
    <button onclick="copyUrl()"><font color="#FF0000">若您使用的是微信小程序,请您点击此按钮粘贴到手机浏览器打开完成支付!</font></button>
</body>
</html>


0
Copyright © 2024