How to redirect from one URL to another URL?

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

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

相关标签:
7条回答
  • 2020-12-05 03:21

    Since you tagged the question with javascript and html...

    For a purely HTML solution, you can use a meta tag in the header to "refresh" the page, specifying a different URL:

    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/somepage.html">
    

    If you can/want to use JavaScript, you can set the location.href of the window:

    <script type="text/javascript">
        window.location.href = "http://www.yourdomain.com/somepage.html";
    </script>
    
    0 讨论(0)
提交回复
热议问题