Redirect without notification in HTML

This question already has an answer here:

  • Redirect from an HTML page 25 answers

  • <meta http-equiv="refresh" content="0; url=http://yoururl.com/" />
    

    or if you want to use JS

    <script type="text/javascript">
       window.onload = function () { location.href = "/root/home.html"; }
    </script>
    

    also works.. just tested it on my server...


    <html>
    <head>
    </head>
    <body>
    
    <script>
    window.setTimeout(function() {window.location.assign("http://www.google.com")},3000);
    </script>
    
    </body>
    </html>
    

    You can use this code. What it does is when you put this Javascript to your html page it will wait 3000 miliseconds and then it automatically redirects to google.com. SetTimeout function is used to wait the specified number of milliseconds, and then execute the specified function.That's what I have done in the above code. window.location.assign("your location name here") is the function which will redirect you to the specified page. You can use this function directly too if you do not want to wait for specific time.


    You haven't specified what (if any) server-side technologies you're using, but I've got to go for a bit, so I'll leave this here in case it's of any use.

    If you're using ASP or ASP.NET, you can use Server.Transfer. This will stop the rendering of the current page, without stopping the current request, and allow you to start the rendering of another page instead. The net effect is that the URL in the browser stays the same, but a different page is sent to the client.

    链接地址: http://www.djcxy.com/p/15718.html

    上一篇: 自动转到其他网站

    下一篇: 无需通知即可在HTML中重定向