<a target="_self" href="https://www.youtube.com" >YT player</a>
Use _self
<a target="_self" href="https://www.youtube.com" >YT player</a>
Answer from O.Rares on Stack Overflow<a target="_self" href="https://www.youtube.com" >YT player</a>
Use _self
<a target="_self" href="https://www.youtube.com" >YT player</a>
Open link in the same tab
<a target="_self" href="https://www.youtube.com" >YT player</a>
Adds a new tab EVERY TIME the link is clicked, and opens the link in it
<a target="_blank" href="https://www.youtube.com" >YT player</a>
Creates a new tab ONLY ONCE, and opens the link in that SAME NEW tab that was created (not creating a new tab every time)
<a target="_new" href="https://www.youtube.com" >YT player</a>
Creates a new tab ONLY ONCE and Opens the link in that same new tab (not creating a new tab every time, and opens the link in the specific tab that was created by its given ID. You can create multiple tabs with different IDs.)
<a target="myYTPlayerTab" href="https://www.youtube.com" >YT player</a>
In case the target attribute of the link matches the name of an iframe that is on the same page, the link will open in that iframe.
<a target="myYTPlayerIframe" href="https://www.youtube.com" >YT player</a>
<iframe src="demo_iframe.htm" name="myYTPlayerIframe" height="300px" width="100%" title="Iframe Example"></iframe>
In case the user is inside a sub frame, it opens the link in the parent iframe
<a target="_parent" href="https://www.youtube.com" >YT player</a>
In case the user is in a frame with in a frame, it opens the link in the top iframe
<a target="_top" href="https://www.youtube.com" >YT player</a>
Videos
Set the target attribute of the link to _blank:
<a href="#" target="_blank" rel="noopener noreferrer">Link</a>
For other examples, see here: http://www.w3schools.com/tags/att_a_target.asp
Note
I previously suggested blank instead of _blank because, if used, it'll open a new tab and then use the same tab if the link is clicked again. However, this is only because, as GolezTrol pointed out, it refers to the name a of a frame/window, which would be set and used when the link is pressed again to open it in the same tab.
Security Consideration!
The rel="noopener noreferrer" is to prevent the newly opened tab from being able to modify the original tab maliciously. For more information about this vulnerability read the following articles:
- The target="_blank" vulnerability by example
- External Links using target='_blank'
Use one of these as per your requirements.
Open the linked document in a new window or tab:
<a href="xyz.html" target="_blank"> Link </a>
Open the linked document in the same frame as it was clicked (this is default):
<a href="xyz.html" target="_self"> Link </a>
Open the linked document in the parent frame:
<a href="xyz.html" target="_parent"> Link </a>
Open the linked document in the full body of the window:
<a href="xyz.html" target="_top"> Link </a>
Open the linked document in a named frame:
<a href="xyz.html" target="framename"> Link </a>
See MDN
You should add the target="_blank" and rel="noopener noreferrer" in the anchor tag.
For example:
<a target="_blank" rel="noopener noreferrer" href="http://your_url_here.html">Link</a>
Adding rel="noopener noreferrer" is not mandatory, but it's a recommended security measure. More information can be found in the links below.
Source:
- MDN | HTML element
<a>| attributetarget - About rel=noopener
- Opens External Anchors Using rel="noopener"
It shouldn't be your call to decide whether the link should open in a new tab or a new window, since ultimately this choice should be done by the settings of the user's browser. Some people like tabs; some like new windows.
Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration and how they click on the link (e.g. middle click, Ctrl+click, or normal click).
Additionally, some browsers don't have a tabs feature and therefore cannot open a link in a new tab, only in a new window.
I made a simple startup page, i used a template i found here on Reddit, and i was able to put it as the default page when i open a new tab and a new window. This page has all the links i use the most.
The thing is.. All the links open on a new tab, and i want to avoid this, since with every link i click, i now have two tabs, one with facebook (for example) and another one with the default page i made with the links.
Is there a way to avoid this? Make all my links open on the same tab without opening new ones.
I hope i make myself clear, english it's not my native language.