Open HTML meta redirect in new window

前端 未结 3 1583
既然无缘
既然无缘 2021-01-21 11:20

I need web page to redirect via HTML meta and open that page in a new window. How can I do that?



        
相关标签:
3条回答
  • 2021-01-21 11:30

    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');">
    
    0 讨论(0)
  • 2021-01-21 11:38

    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.

    0 讨论(0)
  • 2021-01-21 11:41

    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.

    0 讨论(0)
提交回复
热议问题