Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»JavaScript»How to Redirect User to Another Webpage with JavaScript

    How to Redirect User to Another Webpage with JavaScript

    By RahulSeptember 12, 20191 Min Read

    This tutorial will help you to redirect a webpage to another webpage using JavaScript. Here are 3 examples of redirecting webpage to another with JavaScript.

    Advertisement

    Example 1:

    We can redirect user to other page using window.location.replace in JavaScript. window.location.replace has pretty similar to an HTTP redirect.

    1
    window.location.replace("https://example.com");

    Example 2:

    It is better to use window.location.href in place of window.location.replace, because replace() function does not put the originating page in the session history.

    1
    window.location.href = "https://example.com";

    Example 3:

    We can also simply redirect to any internal website page using window.location.

    1
    window.location.href = "/other-page/";

    javascript redirect url website
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    20 Common JavaScript Interview Questions and Answers

    JavaScript Arrays Tutorial for Beginner's

    JavaScript Arrays: A Beginner’s Guide

    How to Get the Current Timestamp in JavaScript

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.