So I'm new to Web Development, and I wanted to know if there was a way to have a hyperlink in HTML, to be opened in a new tab, once clicked on. From there, I would want to have another hyperlink open in that exact same new tab that was opened for the previous hyperlink. Basically I have two hyperlinks that open in the new same tab, versus having the hyperlinks opening in each of their own new tabs. Currently I've been programing this webpage in HTML. Also this is my own project, not school related!
Asked
Active
Viewed 158 times
-4
-
You can use window.open. About it here : http://www.w3schools.com/jsref/met_win_open.asp Usage example here: http://stackoverflow.com/questions/13779508/open-url-in-new-tab-or-reuse-existing-one-whenever-possible – Andrei Terecoasa May 31 '14 at 06:17
-
1Do you have an example of what you've tried? – Patrick Gunderson May 31 '14 at 06:18
-
I have two hyperlinks. If I click on the first hyperlink it will open in a new tab. But then if I were to click on the second hyperlink, it will open on that new tab, that was just opened for the first hyperlink. – user1776479 May 31 '14 at 06:29
2 Answers
0
To make a link open in a new tab, include target="_blank"
in the properties of the a tag:
<a target="_blank" href="xxx.html"> sometext</a>
See also https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
-
1A few words of explanation would turn this from a code sample into an answer. – Jason Aller May 31 '14 at 06:37
0
compare your test
<a href="http://www.w3schools.com/css/css_examples.asp">some text</a>
<a href="http://www.w3schools.com/css/css_examples.asp" target ="_blank">some text</a>

Kisspa
- 584
- 4
- 11
-
Did this need a second answer? Couldn't you include this in the first answer? I'm not really sure that this answers the question at all... – Ben May 31 '14 at 07:32