JavaScript का उपयोग करके दूसरे वेबपेज पर रीडायरेक्ट करने के लिए कोड निम्न है -
उदाहरण
<!DOCTYPE html> <html> <head> <h1>Redirect to a Webpage Example</h1> <button class="redirectBtn">Redirect</button> <h2>Click the above button to Redirect to another Webpage</h2> <script> document .querySelector(".redirectBtn") .addEventListener("click", redirectFunction); function redirectFunction() { location.href("https://tutorialspoint.com/"); } </script> </body> </html>आउटपुट
उपरोक्त कोड निम्न आउटपुट देगा -

"Redirect" बटन पर क्लिक करने पर हम एक नई साइट पर रीडायरेक्ट हो जाएंगे -
