HTML redirect on page load

后端 未结 2 1120
死守一世寂寞
死守一世寂寞 2020-12-16 16:09

I need one of my website pages to instantly redirect to another upon loading. The refresh HTML command does not work, as it does not check whether or not a certain url is be

相关标签:
2条回答
  • 2020-12-16 16:23

    You can wait for a load event with JavaScript and use one of either:

    window.onload = function() {
        // similar behavior as clicking on a link
        window.location.href = "http://stackoverflow.com";
    }
    

    or

    window.onload = function() {
        // similar behavior as an HTTP redirect
        window.location.replace("http://stackoverflow.com");
    }
    

    Source: How to redirect to another webpage?

    0 讨论(0)
  • 2020-12-16 16:35

    Just add a meta tag in the head section of your HTML like this:

    <html>
      <head>
        <meta http-equiv="refresh" content="0;url=http://redirect-to-this-page.com" />
        <title></title>
      </head>
     <body></body>
    </html>
    
    0 讨论(0)
提交回复
热议问题