You'd think I'd be able to work this out from Google, but I've had no luck.
I'm building a content aggregator, imagine a list of links to external sites. Every time I click a link I would like to open a new tab.
At the moment I have target="blank" but what happens is the first link opens a new tab, and all of the subsequent clicks just overwrite the newly opened tab - opening a grand total of 1 new tabs.
As opposed to what I want which is if I click 5 external links, it opens 5 new tabs.
Other aggregators like Digg.com and Delicious somehow manage it, but their a tags's are no different to mine.
Thanks folks
Edit:
Here's how the links are at the moment:
<a class="header" href="/links/56bae5109e1b937548000307/go" rel="nofollow" target="blank">Finding Dory: new posters land</a>
You were close, just make sure there is an underscore _ in front of blank as the value:
<a class="header" href="/links/56bae5109e1b937548000307/go" rel="nofollow" target="_blank">Finding Dory: new posters land</a>
This is because _blank is an actual special word that instructs the browser to open new tab or window. W3Schools:
_blank Opens the linked document in a new window or tab
whereas you had just blank which will be interpreted as a specific window target name, thus all links kept opening to that target.
You should try,
<a class="header" rel="nofollow" target="_blank" href="http://your_url_here.html">Finding Dory: new posters land</a>
If you set the target attribute to "_blank", the link will open in
a new browser window or a new tab.
"blank" causes the result what are you experiencing now,
I have target="blank" but what happens is the first link opens a new
tab, and all of the subsequent clicks just overwrite the newly opened
tab - opening a grand total of 1 new tabs.
like what you said before.
Related
So I already know how to open a link into a new tab by using the target=_blank.
My question is how do you open a second link onto that same tab instead of opening another new tab making three instead of two tabs?
Example:
<a href="allProducts.html" target=_blank>Products</a>
When clicked, should open a new tab.
<a href="allArtists.html" target=_blank>Artists</a>
When this is clicked, should open onto the previous new tab and not open another new tab.
So you should have the initial page, then click on allProducts to get that page on a new tab, and then click allArtists to open onto the allProducts tab to replace it instead of opening a third tab.
You can give the <a>s a common target attribute, one other than _blank, for example:
Products
Artists
Cannot embed due to stack snippet sandboxing, but you can see it in action here:
https://jsfiddle.net/kbqp6dwa/
The following target attribute value will open a link in a new tab:
Visit W3Schools
Why does the following (with underscore in blank omitted) do the same apparently in all browsers? It's a different value?
Visit W3Schools
<a target="_blank|_self|_parent|_top|framename">
target="blank" tries to open an existing frame named 'blank' , so you could use any other word instead of blank , for example target="whatever" see here jsfiddle
so, because the frame(window) with name 'blank' doesn't exist, it opens a new window and you have the impression that is the same thing with _blank, but _blank is a reserved value for the target attribute
target="_blank" opens the given url in a new window
target="whatever" targets a window named 'whatever' , if that window does not exist, it creates a new window
for more info read here HTML target Attribute
target=blank opens the link in a new window entitled blank where target=_blank just opens it in a new window. So if u have two links w/ target=blank then they will both open up in the same new window but if u have the two links w/ target=_blank they will both open up in their own new window.
blank targets an existing frame or window called "blank". A new window is created only if "blank" doesn't already exist.
_blank is a reserved name which targets a new, unnamed window.
Back in the day, I could make a link with a target like this:
<a href="https://example.com/something" target="frameName" />
If a frame named frameName didn't exist on the page, the link would open in a new window/tab. That still works today. Now, add a second link:
<a href="https://example.com/somethingElse" target="frameName" />
If I click the first link, it opens in a new tab/window. If I then click the second link, I would expect it to open in that same tab/window that was opened for the first link. However, this isn't happening. Instead, the second link opens up in its own new tab/window.
Has this behavior changed? How can I get the old behavior back?
Since I approached the web programming, to open a link in a new window I always used
target="blank"
but most of the time, here and in the rest of the web I have ever seen use:
target="_blank"
Both forms work (of course), but I do not know the difference between the two versions and they do not know what the correct way (and why)....
blank targets an existing frame or window called "blank". A new window is created only if "blank" doesn't already exist.
_blank is a reserved name which targets a new, unnamed window.
In short, use target="_blank" it always open a new window but use target="blank" it will open a new window at the first time and this window will be reused after the first.
Both target="_blank" && target="blank" will open new window or tab.
The difference is
target="_blank"
On every click, it will open in a new window.
target="blank"
On another (Multiple) clicks, it will Open in the same window that opened for the first click (reuses the same tab).
It reuses the same tab for all the linked documents with attribute ="blank"
When exactly links should open in a new tab/window? I find that some of the actions which require certain operations in a new tab/window can be done on the same page using modal windows and then refreshing the same page to show the updated contents.
A couple of google searches gave me the following results:
Why external links should open in new tabs?
When if ever should links be opened in a new window?
Is there ever a good reason to force opening a new browser window?
Should links open in new windows?
Forcing links to open in new windows: an argument that should have ended 15 years ago
Some suggest that in case of external links they should be opened in a new tab/window, some suggest that they should be opened on the same page for simplified user control. Both of them sound correct in their own ways. Isn't there some sort of generalization? Or are there any particular situations where we cannot do without links opening in a new tab/window?
In other words, what are the situations where a link should open in a new tab/window OR in the same page (taking into account that modal windows are implemented frequently these days)?
Having external links opened in a new tab is better and done more often so that when you have a user surfing your site and clicks on an external link he doesn't have to go back but simply just needs to close that tab and can continuous surfing your site.
You have to bare in mind that not ever internet user knows how to work with a browser like you do (Still many lesser-intelligent people on the net).
add attribute target="_blank" on a tag
Link 1</strong></p>