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"
Related
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.
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.
I have been using something like so, Some text, for almost 3 years now and I want to make sure I am not doing something terribly illegal.
After looking up some info I started to notice everywhere stated it as target="_blank". This started to bring some concern to me that I may need to go back through all of the websites I have worked on and make changes to include _.
When I run it through the validator it does not cause an error and does not even inform me of a warning pertaining it.
My question:
Is this against the guidlines to not use the, _, underscore?
If this is against the guidelines then why does it not cause an
error and why does it work?
As a side note, I couldn't find much info on this but I at least found the specs for links.
_blank means "Open a new, unnamed window"
blank means "Use a window/tab/frame named 'blank'"
If you click on a second link with target="blank" then it will open in the same window as the first target="blank" link.
The target attribute can either be the name of a frame (which can be anything), or one of three special names that start with _.
target="blank" means open in window named "blank". If the window named "blank" already exists, it will open site in that window. May be a frame in document.
target="_blank" means open in new window.
Strictly-speaking, what you're doing (not using the underscore) is incorrect.
If you opt to simply use target="blank" then your link will still open correctly but with a subtle difference: clicking on the link will reuse the window opened last time instead of opening a new one.
This is because the target attribute contains the name of the frame the link should open in. If a frame with the name 'blank' (as you're declaring) doesn't exist then it will open a new window and designate it with that name. So, whenever another link within your page that also contains target="blank" is clicked upon, it's the same window that was opened last time (assuming that it's still open) that will change.
Basically, there's no massive need for you to go back through your old websites changing everything you've done, but you should consider changing to target="_blank" going forward if what you intend is for it to open a new tab/window each time.
I have an image map with one of the following entry
<area shape="poly" tooltip="Canada"
onmouseover="setAreaOver(this,'world_canvas','0,0,255','255,0,0','0.5',1,0,0);cvi_tip._show(event);"
onmouseout="setAreaOut(this,'world_canvas',0,0);cvi_tip._hide(event);"
onmousemove="getCoords(event,'map_of_world','map_of_world_6','world',32,371,800,400,1903,2876);cvi_tip._move(event);"
href="http://someurl.com"
target="_blank"
id="map_of_world_6">
UPDATED
I am using Google Chrome and I removed the coords attribute from the snippet because it is too long.
Upon clicking on the area the main page goes to the url instead opening on the new page. Is this the right way to use target=_blank?
Your syntax for the target attribute is correct, but browsers need not honor it. They may interpret it as opening the destination in a new tab rather than new window, or they may completely ignore the attribute. Browsers have settings for such issues. Moreover, opening of new windows may be prevented by browser plugins (typically designed to prevent annoying advertisements).
There’s little you can do about this as an author. You might consider opening a new window with JavaScript instead, cf. to the accepted answer to target="_blank" is not working in firefox?, but browsers may be even more reluctant to let pages open new windows that way than via target.
onclick="window.open(this.href,'_blank');return false;"
This is my code:
test
When you click it, it takes you to Yahoo but it does not open a new window?
test
Easy as that.
Or without JS
test
In order to open a link in a new window, add Javascript command
onclick="window.open('text-link.htm', 'name','width=600,height=400') inside the <a> tag:
Open page in new window
Given answer might be helpful when you want to open a new tab or browser user preference is set to open new window instead of tab, since the original question is about open new window not a tab, here is what works for me.
<a href="#" onClick='window.open(url, "_blank", "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=600);'>test</a>
Check this one too