在新窗口打开HTML元重定向

3
我需要一个网页通过HTML meta重定向并在新窗口中打开该页面。我该如何做到这一点?
<!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>

你能在“照片库重定向”上再添加一些内容吗? - microspino
哦,为什么?是有客户要求吗? - Aryabhatta
4个回答

11

你可以做到这一点!当刷新在iframe中运行时(例如Facebook应用程序画布页面),您希望刷新加载内容到主窗口(父级窗口)时,它尤其有用。

在meta重定向中使用以下Javascript:

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

1
非常好,谢谢!已经测试并且可以将SharePoint链接转换为.htm文件 :) - Jason K.

4
你不能使用 meta 重定向来实现这个功能。需要使用 JavaScript。
<script type="text/javascript">window.open('http://google.com');</script>

要么在导致“照片库重定向”页面的链接/表单中添加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"加入其中。

请注意弹出窗口阻止器,避免未经请求的弹出窗口。 - Mitch Dempsey

1

不行。你需要使用JavaScript定时器来打开一个弹出窗口(大多数浏览器可能会将其阻止,因为它是未请求的弹出窗口)

你可能最好采用不同的方法来解决你的问题。


0

不使用url属性,就像这样制作

<meta http-equiv="refresh" content="5;https://stackoverflow.com">


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接