Need drupal_goto() result in a new tab (target=blank)

Events happening in the community are now at Drupal community events on www.drupal.org.
sarath.verve's picture

Hi All,

I want the drupal_goto() result in a new tab. I couldn't find a solution anywhere here. Can anybody help me for this...

Thanks in advance for ur help....!

Comments

Adding target="blank" to URLs

frank ralf's picture

You should find some pointers at Target des Weiterlesen-Links ändern?, in German, but links to English resources as well and some code snippets.

hth
Frank

Hi Frank, Thanks for your

sarath.verve's picture

Hi Frank,

Thanks for your swift reply.

What I want is
drupal_goto("www.google.com"). Need to open this in a new tab. How can I pass target=_blank in this function?
Thanks for your help..

Hi

ericBaneton's picture

Hi,
You can also use drupal_add_js to use the window.open.

++
Eric.

drupal_get_destination()

frank ralf's picture

AFAICT you could pass your attribute(s) within a query built with drupal_get_destination() to drupal_goto().

Why do you want to use drupal_goto() for external links in the first place?

Probably going about this the wrong way

BrockBoland's picture

drupal_goto() will immediately print out a 'Location:' header and exit the currently-running script. You cannot open a new tab from a server-side script.

So maybe we should back up a bit: what's the use-case here? As ericBaneton notes, you could add some Javascript to the page that will open a new window when the page finishes loading, but that might not be ideal exactly because it doesn't happen until the page finishes loading. If you can clarify what you're trying to do, we can give better answers.

Hi Brock, I am having a

sarath.verve's picture

Hi Brock,

I am having a custom form, say search and i want to show the result of this form submit in a new tab. As of now, I am giving drupal_goto('to my result page'). But its loading in the same page. I want to show this in a new page. Is there any other method other than drupal_goto.. Thanks for ur help :)

I think what you want to do

btopro's picture

I think what you want to do is when you click submit, it actually opens in a new window and THEN performs your drupal_goto stuff. For accessibility purposes I'd probably recommend against making a decision for the user (as annoying as it can be) about what they want to do. We just got told not to do that and are starting to remove target="_blank" all over the place.

What btopro says is correct -

kat3_drx's picture

What btopro says is correct - forcing target="_blank" is an accessibility issue. Ifyou can do without it, so much the better. If you absolutely, positively have to do it or the world will end, consider adding a note on the link along the lines of "line name (opens in a new tab/window)."

Hi btopro/kat3_drx, Thanks

sarath.verve's picture

Hi btopro/kat3_drx,

Thanks for help.. I am not using target = "_blank" as u suggested.

Thank you team...!

For me, I want the detail

wanfju19's picture

For me, I want the detail node page open in new window, but I want other link like menu page do not open in new window, so I add below code in page.tpl.php:

$('.field-item a').each(function(index, value){
$(this).attr("target","_blank");
}

because under .field-item div all link is open a node page for my applicaiton.

Thanks

i'm facing the same problem

proxyninjas's picture

i'm facing the same problem as sarath.verve...

Emma Wilson
Private Proxy Ninjas
http://www.ninjasproxy.com/private-proxy

We cant open a new tab from server side.

dharam1987's picture

I hope you know this concept, but would like to explain the same again so that it might be helpful for others.

drupal_goto() executes at server, and our server has no link with browser when this code gets executed, the server will simply redirect to the URL and serve that page to the browser and it will load in the same page.

You may use the options like window.open etc and take care of this using javascript.

Dharmendra Patri
Learning never stops, I am no better than you just because I know something which you don't know.Everybody has some special skills which the other person don't have. Never underestimate your self and step forword towards your goals.

Washington, DC Drupalers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: