【问题标题】:How to automatically redirect to anothe html page如何自动重定向到另一个html页面
【发布时间】:2014-04-21 05:03:24
【问题描述】:

我想将 html 页面重定向到另一个 html 页面。在我的代码中,它正在重定向。当它被重定向时,原始的 html 页面应该关闭,并且它不应该要求警告,如允许在重定向的 html 中被阻止的内容。

【问题讨论】:

  • 取决于时间。您不想显示当前页面并重定向吗?你想在用户做某事后重定向吗?等等
  • 是的。我不想显示原始的 html 页面,它应该重定向到另一个 html pae,它不应该在重定向的 html 页面中询问被阻止的内容警告。

标签: html


【解决方案1】:

最简单的方法是使用javascript:

window.location.href ='http://google.com'; //link to redirect to

只需将其粘贴在 <head></head> 或正文中即可。

最好/正确的重定向方式是通过服务器。无论是使用 htaccess 还是 PHP,最好在用户加载页面之前重定向。在 PHP 中,它会是这样的:

<?php 
header("Location:http://google.com");
exit; //make sure nothing gets loaded after

【讨论】:

    猜你喜欢
    • 2015-03-09
    • 2013-09-05
    • 1970-01-01
    • 1970-01-01
    • 2015-01-17
    • 2021-01-08
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    相关资源
    最近更新 更多