You must Sign In to post a response.
  • Category: JQuery

    How to redirect to home page in jQuery?

    Hi,
    When I complete an action in jQuery, I redirect user to home page in jQuery using below statement.

    location.href='/';

    This works fine in localhost. But, when this code is put in online server, it does not work.

    I tried "location.href='~/''", but it does not work in localhost also.

    How to do this in jQuery?
  • #758026
    Hello Arul,

    Use the below code to redirect to home page:
    // similar behavior as an HTTP redirect
    window.location.replace("~/");

    // similar behavior as clicking on a link
    window.location.href = "~/";

    Hope it will help you.
    Mark the answer if you are satisfied.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758027
    Better is you can put home page name as defult.aspx, index.aspx or any other which page is treated as home page in your application.
    Regards & thanks
    Arvind kumar
    Visit--blog.akumars.esoftera.in


  • Sign In to post your comments