function startRedirect() { // Get URL from query parameter const urlParams = new URLSearchParams(window.location.search); const redirectUrl = urlParams.get('url') || 'https://example.com'; // Default URL if none provided // Validate URL if (!redirectUrl.startsWith('http://') && !redirectUrl.startsWith('https://')) { alert('Invalid URL!'); return; } // Display target URL const targetUrlElement = document.getElementById('targetUrl'); targetUrlElement.innerHTML = redirectUrl; // Display countdown and progress bar let timeLeft = 10; const countdownElement = document.getElementById('countdown'); const progressBar = document.getElementById('progressBar'); countdownElement.style.display = 'block'; progressBar.style.display = 'block'; countdownElement.innerHTML = `Redirecting in ${timeLeft} seconds...`; // Disable button document.querySelector('.btn').disabled = true; // Start countdown const countdown = setInterval(() => { timeLeft--; countdownElement.innerHTML = `Redirecting in ${timeLeft} seconds...`; if (timeLeft <= 0) { clearInterval(countdown); window.location.href = redirectUrl; // Redirect } }, 1000); } // Display target URL on page load window.onload = function() { const urlParams = new URLSearchParams(window.location.search); const redirectUrl = urlParams.get('url') || 'https://example.com'; document.getElementById('targetUrl').innerHTML = redirectUrl; };