URL Shortener Tool - Shorten Your Links Instantly

URL Shortener Tool



<script>
    const form = document.getElementById('shortenForm');
    const resultDiv = document.getElementById('result');

    form.addEventListener('submit', (event) => {
        event.preventDefault();
        const url = document.getElementById('url').value;
        shortenURL(url);
    });

    async function shortenURL(url) {
        try {
            const response = await fetch(`https://api.vvhan.com/api/short?url=${url}`);
            const data = await response.json();
            resultDiv.innerHTML = `<p>Shortened URL: <a href='${data.url}' target='_blank'>${data.url}</a></p>`;
        } catch (error) {
            resultDiv.innerHTML = `<p>Error: ${error.message}</p>`;
        } 
    }
</script>
URL Shortener Tool - Shorten Your Links Instantly

原文地址: https://www.cveoy.top/t/topic/pbmg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录