Redirect via JavaScript

Sometimes you need to redirect to a page from client side JavaScript. You can do this in two ways:

  • Go to a specific page with a “link pressed” like behavior. That means that your current page will be put into the browser’s back stack:
    window.location.href = "";
  • Do not add the current page to the back stack. This is very similar with a server side redirect:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s