/    Sign up×
Community /Pin to ProfileBookmark

Opening a link in a new tab?

Hi! What is the code to open a link in a new tab?

Thanks.

Firblazer

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 27.2007 — That is under the control of the user not you.
Copy linkTweet thisAlerts:
@Mr_MooAug 27.2007 — There is no code that can specifically open a link in a new tab. Opening links in tabs or as new windows is a user option and cannot be controlled from JavaScript.
Copy linkTweet thisAlerts:
@firblazerauthorAug 27.2007 — There is no code that can specifically open a link in a new tab. Opening links in tabs or as new windows is a user option and cannot be controlled from JavaScript.[/QUOTE]

I thought there is a code to open a link in a new window:

[CODE]<A HREF="javascript:popUp('location')">Open the Popup Window</A>[/CODE]


I thought maybe there is something similar to open a link in a new tab?

Thanks.
Copy linkTweet thisAlerts:
@firblazerauthorAug 29.2007 — Does anybody else know the answer?

Thanks.
Copy linkTweet thisAlerts:
@hoangkcAug 29.2007 — using target attribute.

by default, target is the same window,

if target = name of frame, Linked document loads into that frame,

here, you can set target="_blank" (it doesn't make sense) but it works in IE7 and FF (with default browser setting)
Copy linkTweet thisAlerts:
@Mr_MooAug 29.2007 — I'm afraid target won't make windows open in a new tab either. Not by default, anyhow.

By default in IE7 the options are as follows:

[ATTACH]9531[/ATTACH]

Now, in the second group, if you switch to Let IE decide or Always open in a new tab, it will work. However, that is not the default. As far as I can remember the same is true for FF (I can't really test it because my FF is so customized it's barely recognizable anymore). In Opera it appears to work out of the box. There is an option to show windows instead of tabs, but it's not default.

All this to say, that ultimately it's a user setting. It's not default in IE and FF, and there's no way to force the opening of a new window in a tab from script.

[upl-file uuid=5524463d-fd1c-41dc-9ee3-9ab0b340db75 size=37kB]openInTab.jpg[/upl-file]
Copy linkTweet thisAlerts:
@felgallAug 29.2007 — The browser owner can decide whether to have all new pages open in the same window, a new tab, or a new window. They can also make separate decisions for links to separate sites and links within the same site. If they configure their browser to work their way then any target= attributes and window.open calls will open the way they want regardless of what you intended.

target= is deprecated because it is a behaviour and not content and so should be handled by JavaScript and not HTML.

window.open() will open in a new window if it isn't blocked by a popup blocker and the browser owner hasn't configured their browser to have it open in a new tab or the same tab instead.
×

Success!

Help @firblazer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...