By rezvani63 on
Hi Drupal developers,
How can I set one of my primary links to be opened in a new tab or new window? This case can be extended to all menu items, so the menu module may be developed to add a custom setting to each menu item to specify how to be opened?
Your kindly response is appreciated.
Comments
Off-hand I'm not sure how to
Off-hand I'm not sure how to do it... I wanted to let you know though that, unless its a client demanding this feature or you have a special/necessary reason for it, I'd suggest that you do not do it. Currently on the web its considered bad etiquette for a site to open new windows when users click links/menus.
-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides
Thanks David, but sometimes
Thanks David, but sometimes you need to direct one special link to a new tab. In my case I have a link among my primary links that my customer asked me to be opened in a separate tab. So I have to perform his request. So what is the best solution?
You could refer to the
You could refer to the discussion on this link: http://drupal.org/node/260104
Bad web etiquette?
Bad web etiquette? That seems odd. The reverse seems more true in the case of Drupal. What if the link takes the visitor away from a Drupal-formatted page with the menus visible? That forces the visitor to use the back button to get back to those menus when simply closing the new page would be much easier and, for me at least, more logical. Or, if desired, s/he can switch back to the Drupal page and open another link.
"Etiquette" seems a poor substitute for allowing existing functions to operate as designed.
add target blank to menu link
add following jquery code to your page.tpl.php file in head area
$(document).ready(function(){ $('#id').children(":first").attr("target", "_blank"); });provided that jquery must be run on your machin.
where #id is your li tag id
Opening a primary link in a new tab or window (_blank)
Opening a primary link in a new tab or window (_blank):-
add following jquery code to your page.tpl.php file in head area
$(document).ready(function(){ $('#id').children(":first").attr("target", "_blank"); });provided that jquery must be run on your machin.
where #id is your li tag id
sagar bhoir
+919892265793
Hi All, I have been asked
Hi All,
I have been asked from my client to do the same... and It's very bad etiquette for keeping menus so strict. I am sure many of us are facing this issue. as a developer i feel discomfort with these rules.
adding the following jquery code to your page.tpl.php file in head area might solve issue for one time.
But i think there must be a better way to make these things user friendly for developers. as always the requirements are dependent on the client.
I am in a journey to find better way... help me
If you are ok with Jquery its
If you are ok with Jquery its fine, otherwise you can try this module: http://drupal.org/project/menu_attributes
Thanks
regards
Dev/Kuldev
Hi Devtherock, this is really
Hi Devtherock,
this is really a great module... i have tried it on dev site looks awesome.
http://drupal.org/project/ext
http://drupal.org/project/extlink
For all those who are still looking - the above module is what you need
using l() function
add the target attribute to the l() function: