views:

150

answers:

3

Hey so I set up a right click menu on my site you can see here

http://www.jaminproud.com

Everything works good except I want to add the abilty to open a link in a new tab. I have looked everywhere and cant find a solid answer for this. I would also need a way to make the menu so that option is only displayed while hovering over an anchor tag. Thanks in advance for any help.

P.S I dont need the actual code written that would be nice but rather just to be pointed in the direction Thanks.

A: 

You need to save the element that was clicked on in the click event handler from the event object's target property. You can get the tag name using the element's nodeName property, and if it's an A element, you can get the URL using the href property.

SLaks
A: 

Tabs are browser specific, so you probably just want to open it in a new window by specifying the target attribute in the link like so:

<a href='somewhere.html' target='_blank'>My Link</a>

Most tabbed browsers will let the user specify if they want it opened in a new tab or a new window when one of these type of links is clicked.

Topher Fangio
+2  A: 

There is now way to specify opening in a new tab yet, but when new browsers support CSS3 we will have the ability to tab link.

See: http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/#target-new

For now, why not just use target="_new" ?

jeph perro
Small typo."There is [no] way to"...
Daniel Ballinger