जावास्क्रिप्ट का उपयोग करके किसी अन्य वेबपेज पर रीडायरेक्ट करने के लिए, कोड इस प्रकार है -
उदाहरण
<!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> आउटपुट
उपरोक्त कोड निम्न आउटपुट उत्पन्न करेगा -

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