avoid a page being added to browser history when redirecting using a meta http-equiv tag

前端 未结 2 1433
无人共我
无人共我 2021-02-15 04:01

I have a web page, that redirects to the desired destination url using:


相关标签:
2条回答
  • 2021-02-15 04:42

    Your two options are to either use a real HTTP redirect, or to use JavaScript's location.replace.

    The former is better, but if there's some reason you can't do it, location.replace can work as an alternative:

    document.location.replace(redirectURL)
    

    location.replace actually replaces the current location in the browser history, so the back button will not go back to the redirection page. If you do this you may also want to include a meta refresh with a short timeout as a fallback if you expect any of your users to not have JavaScript.

    0 讨论(0)
  • 2021-02-15 04:42

    You can't.

    If you want to redirect, use an HTTP redirect. <meta> redirects have many flaws, and this is one of them.

    0 讨论(0)
提交回复
热议问题