Gravity page redirect in new tab

Is there any way to open page redirect in new tab. I had already used the given hook by gravity form which is following. But my page dont have wp_head and wp_footer included. I think that’s why that hook is not working. Is there any other way to do this with JS script??

add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry, $ajax ) {
    GFCommon::log_debug( _METHOD_ . '(): running.' );
    if ( isset( $confirmation['redirect'] ) ) {
        $url = esc_url_raw( $confirmation['redirect'] );
        GFCommon::log_debug( _METHOD_ . '(): Redirect to URL: ' . $url );
        $confirmation = 'Thanks for contacting us! We will get in touch with you shortly.';
        $confirmation .= "<script type=\"text/javascript\">'$url', '_blank');</script>";
    return $confirmation;
}, 10, 4 );

Hi Jesse. This code is pretty simple. It just takes the confirmation URL you set in the Confirmation settings, shows a quick message (Thanks for contacting us! We will get in touch with you shortly) and then appends the redirect script. It’s not even jQuery, just JavaScript.

Try using the script in a plain text confirmation by itself, without the gform_confirmation filter to see if that works. You will need to set the $url yourself, because you would not be using the filter.

You could put this by itself in the confirmation text to try it ( I just tried it and it worked ):

<script>'', '_blank');</script>

There are no dependencies on jQuery or anything like that, so it should not matter if there is wp_head or wp_footer.

I tried but I can’t succed to open in a blank page …
And I need to sen datas to the query string
I need this solution for only one of my three forms …
please help me

Hi Julien. I know you have already opened a support ticket and that Karl has replied, so please continue to follow up there. Thank you.

I have got the filter working (it is writing to the log fine) but have not been able to get the Redirect to open in a New Tab.

Have tried on Chrome, Safari and Firefox on Mac, and it almost feels like the browser is stepping in and preventing the New Tab from happening as a security measure or something (like a “Pop-Up Blocker” type thing)?

Can anyone confirm the this method of opening a redirect confirmation in a new tab still works in modern browsers?

Thank you

Hi @heavyside. I think it is browsers that prevent that. The workaround we published a few years is no longer working the way it did to open the redirect confirmation in a new tab/page. We don’t have a workaround at this time, and we are looking at taking that page down, as it has been creating more questions than solving problems, for a while now. I will leave this open in case someone else has a working solution.

Hi @chrishajer , Thank you for following up on this one. While it isn’t what I was hoping to hear, I appreciate the response.

Removing the outdated code altogether is probably wise, but if not, I think it would certainly be a good idea to mention on the page (perhaps even as a comment in the code example) that changes to browser behaviour have largely rendered the code useless. :slight_smile:

I agree with you completely. I’ll see if we can make that happen. If we come up with another workaround, I’ll share it here.