Open HTML meta redirect in new window
I need web page to redirect via HTML meta and open that page in a new window. How can I do that?
<!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-e开发者_如何学JAVAquiv="Refresh" content="0; url=http://google.com">
</head>
<body>
</body>
</html>
You can do this! It is particularly useful when the refresh is being run in an iframe (such as a Facebook app canvas page), and you want the refresh to load the content to the main (parent) window.
Use the following Javascript in your meta-redirect:
<meta http-equiv="refresh" content="5; URL=javascript:window.open('http://google.com','_parent');">
You can't do that with a meta redirect. Grab JavaScript.
<script type="text/javascript">window.open('http://google.com');</script>
Either that, or add target="_blank"
to the originating link/form which landed in this "Photo Gallery Redirect" page.
<a href="http://google.com" target="_blank">click here</a>
or
<form action="http://google.com" target="_blank">
<input type="submit" />
</form>
Not XHTML/HTML5 valid, but it works. Else you can just add rel="ext"
and use some piece of Javascript to silently put the target="_blank"
in anyway.
You can't. You need to use javascript on a timer to open a popup (which most likely will be blocked by some browsers as an unrequested popup window)
You are probably better off taking a different approach to your problem.
make it without using url attribute just like this
<meta http-equiv="refresh" content="5;https://stackoverflow.com">
精彩评论