-1

Possible Duplicate:
Programmatically open new pages on Tabs

I have a link in my page and i want it to be opened in a new tab when the user clicks it?

Community
  • 1
  • 1
Jishnu A P
  • 14,202
  • 8
  • 40
  • 50
  • 2
    possible duplicate of [Programmatically open new pages on Tabs](http://stackoverflow.com/questions/427479/programmatically-open-new-pages-on-tabs) Sadly the answer hasn't chnaged since then (Jan '09) – T.J. Crowder Dec 23 '10 at 12:09
  • 2
    If you do this, I will not use your app. This is a general rule: screw with my user-browser interaction semantics and I will be unhappy. Very unhappy. – dmckee --- ex-moderator kitten Dec 24 '10 at 03:54
  • 1
    Why cant u use google to find such basic answers??? You have pretty good reputation and we expect u to google it before posting a question in a site like Stackoverflow.. –  May 26 '11 at 12:15

4 Answers4

5

That depends on the users browser settings. You can't control that as far as I know. All you can do is get it to open in a new windows, but if the user has his/her browser setup to open new windows in a new tab, it will do that.

So basically, the best you can do is open in a new window.

target="_blank"

i.e.

<a href="url here" target="_blank">link text here</a>
oshirowanen
  • 15,297
  • 82
  • 198
  • 350
1

Most browsers treat a _blank target as opening in a new tab.

Set the target to _blank:

<a href="mypage.aspx" target="_blank"></a>
Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90
0

Use the target attribute set to _blank:

<a href="http://example.com" target="_blank">example</a>

The exact behavior depends on the browser and user settings, so this is the best one can do.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

This is considered bad practive because you (the web developer) is trying to control what the users browser is doing. It should be up to me how I want to open the link. Other than that lecture (and I understand that this may not be your decision), it doesn't seem that there is a way to do this.

calumbrodie
  • 4,722
  • 5
  • 35
  • 63