Open a new window on redirect
I have a form set up that redirects the user to a different site after submitting the form. Is there a way to open this page in a new window?
I have a form set up that redirects the user to a different site after submitting the form. Is there a way to open this page in a new window?
PHP is server-side.
A new pop-up window is client-side.
Usually this is done with either the target="_blank" attribute in a link, or with javascript using window()
I suppose you could set your php redirect with a get parameter, and use this condition to trigger a script
<?php
if (isset($_GET['popup'] )) { ?>
<script>
window.open("page name", $other_attributes_here );
</script>
<?php } ?>
Thanks for the reply. I'll give this a shot but I'm not sure where to put this in the code, could you help me out with that? I have the page attached to the previous post.
PM (if required)
If you change your form, so the redirect points to a new (internal) page, lets say external.php.
set the redirect url as follows... /external.php?popup=true
create a new page called external.php, add the following code within the <head></head> tags
<?php
if (isset($_GET['popup'])) { ?>
<script>
var win = window.open("http://google.com", '_blank');
win.focus();
</script>
<?php } ?>
changing the url to the one you need
This should work as long as the browser doesn;t have popups blocked
That worked perfectly but there was only one problem. The issue is that the page containing the form (needs.php) has instructions for the site that they're redirected to. So I need the needs.php page to remain open so that they can reference that but it's showing external.php.
A couple of things spring to mind.
1. Instead of redirecting to a new internal page first, just redirect the page to itself, but include the url parameter in the redirect, then add the conditional javascript in the head section.
2. If this doesn't fulfil your needs, can you store whatever values you need in a session variable ?
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.