How to redirect from one URL to another URL?

前端 未结 7 694
忘了有多久
忘了有多久 2020-12-05 02:22

How can I redirect to another URL in a web page using JavaScript?

7条回答
  •  余生分开走
    2020-12-05 03:14

    window.location.href = "URL2"
    

    inside a JS block on the page or in an included file; that's assuming you really want to do it on the client. Usually, the server sends the redirect via a 300-series response.

提交回复
热议问题