【问题标题】:Open HTML meta redirect in new window在新窗口中打开 HTML 元重定向
【发布时间】:2010-05-17 19:34:18
【问题描述】:

我需要网页通过 HTML 元重定向并在新窗口中打开该页面。我该怎么做?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Photo Gallery Redirect</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <meta http-equiv="Refresh" content="0; url=http://google.com">
    </head>
    <body>
    </body>
</html>

【问题讨论】:

  • 你能在“照片库重定向”上做更多的广告吗
  • 天啊。为什么?有客户要求吗?

标签: html


【解决方案1】:

你可以做到!当刷新在 iframe(例如 Facebook 应用画布页面)中运行并且您希望刷新将内容加载到主(父)窗口时,它特别有用。

在您的元重定向中使用以下 Javascript:

<meta http-equiv="refresh" content="5; URL=javascript:window.open('http://google.com','_parent');">

【讨论】:

  • 非常好,谢谢!经过测试并努力将共享点链接制作为 .htm 文件:)
【解决方案2】:

您无法通过元重定向来做到这一点。抓取 JavaScript。

<script type="text/javascript">window.open('http://google.com');</script>

要么添加target="_blank",要么将target="_blank" 添加到此“照片库重定向”页面中的原始链接/表单。

<a href="http://google.com" target="_blank">click here</a>

<form action="http://google.com" target="_blank">
    <input type="submit" />
</form>

不是 XHTML/HTML5 有效的,但它可以工作。否则,您可以添加 rel="ext" 并使用一些 Javascript 将 target="_blank" 静默放置。

【讨论】:

  • 当心未请求的弹出窗口的弹出阻止程序。
【解决方案3】:

你不能。您需要在计时器上使用 javascript 来打开弹出窗口(很可能会被某些浏览器阻止为未请求的弹出窗口)

您最好采用不同的方法来解决您的问题。

【讨论】:

    【解决方案4】:

    像这样不使用url属性就可以了

    &lt;meta http-equiv="refresh" content="5;https://stackoverflow.com"&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-24
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      相关资源
      最近更新 更多