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;"
Related
I'm working on an application that has many links. They all open in the same window, until today. All of a sudden, in all browsers I'm testing in, 3 links in an iframe or object (I've tried both) start opening in a new window. I can't seem to stop this.
An object example follows. The dolnks program generates 3 simple links like the one following the object example and these links open in a new window.
<OBJECT ID='fixed' DATA='dolnks.cgi?str=$params' TARGET='dynamic' NORESIZE></OBJECT>
darea.cgi?str=$dogstr
Can someone help me understand this and how to get these links to open in the same window.
All links that now open in the same window or should be opening in the same window are from
the same domain.
I now have to close the link instead of using the back button.
Thanks,
craigt
I imagine it's because of your TARGET attribute, although it's not using one of the special target values:
target
Where to display the linked URL, as the name for a browsing context (a tab, window, or ). The following keywords have special meanings for where to load the URL:
_self: the current browsing context. (Default)
_blank: usually a new tab, but users can configure browsers to open a new window instead.
_parent: the parent browsing context of the current one. If no parent, behaves as _self.
_top: the topmost browsing context (the "highest" context that’s an ancestor of the current one). If no ancestors, behaves as _self.
From the MDN Docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes
Note though that the docs for object do not list a target attribute, so that behavior is apparently undefined, and probably varies depending on the browser, and the plugin displaying the object.
Check to see if it's the items with a target attribute (case does not matter) that are working "wrong", and see if removing that attribute fixes it. If that's not it, next check to see if there are javascript being loaded. Try turning javascript off (hopefully the relevant links are not generated with javascript) and see if that fixes the behavior. If turning javascript off is too heavy handed, you can use the javascript console to see what listeners are attached to the links.
I have a html page with several links to files with various file types, such as pdf, csv, and zip. Depending on the available browser plugins, some of these files can be opened inline by the browser, whereas others will be downloaded.
I don't want such links to open in the current tab, so each one has the attribute target="blank".
This works fine in most browsers:
When the user clicks on a link to a file that can be displayed inline, the file is shown in a new tab.
Otherwise, a new tab is opened and immediately closed as soon as the file starts to download. The user stays in the current window.
In Microsoft Edge, however, the second case does not work: the new tab remains open. This is annoying, because the user is now looking at a useless empty tab.
Is there any way to prevent this from happening?
I don't think there is anything you can prevent Edge's this behaviour. What you can do is to change the HTML tag.
Use download attribute in <a> element without target attribute. This way, the browser will prompt save dialog instead of opening a new tab.
<a href="myfile" download>Download</a>
http://www.w3schools.com/tags/att_a_download.asp
In this case, the browser will not display the file inline.
If you still want your clients be able to see the files inline you can detect the client's browser; if it is Edge then use the download attribute, if not use target attribute. In addition, you can use something like navigator.mimetypes to detect which file types can be displayed inline (see https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins/mimeTypes).
Here is the detect function which I took from another post (How can I detect Internet Explorer (IE) and Microsoft Edge using JavaScript?)
function isEDGE(){
return /Edge\/\d./i.test(navigator.userAgent)
}
Leave your <a> tags with no target and download attributes. Use detect function and decide on the right attribute.
Like this:
$(document).ready(function(){
if(isEDGE()) {
$('a').attr('download','download');
} else {
$('a').attr('target','_blank');
}
})
Note:
I am not sure about Edge detecting function.
Method 1:
I suggest you clear the Clear browsing data option of Microsoft Edge and check if you face the issue. To do so perform the steps below.
Click on the More actions icon next to the feedback icon present on top right corner of the Edge.
Select Settings and click on Choose what to clear.
Check the boxes Browsing history, Cookies and saved website data and Cached data and files and click on Clear.
Method 2:
If you are using any Proxy connection, then try disabling the proxy connection and check.
Follow the steps to disable proxy:
Click the Settings icon at the top right corner in internet explorer.
Click the Tools button, and then click Internet Options.
Click the Connections tab, and then click LAN settings.
Uncheck the box next to “proxy server for your LAN”.
Click on OK to save the setting and close window.
Now check the issue by opening Edge.
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.
There seems to be an odd behavior when using the target attribute in a link, e.g.:
<ul>
<li>Opernhaus</li>
<li>Powerhouse Museum science+design</li>
<li>Botanic Gardens</li>
</ul>
The last link causes that whatever link is clicked afterwards a new browser window is being opened. The expected behavior is to open the link in the browsing context "sehenswuerdigkeit" (= "place of interest"). All other links work fine. It seems like opening this site destroys the browsing context.
I've tried it using Chrome 17, Safari 5.0.1 and Firefox; working on Mac OS 10.5.
I believe it's actually the second link sir...it is corrupting the target with javascript.
http://www.powerhousemuseum.com/
target in this sense is not a location, it is for the browser to tell what it needs to do.
Try making target="_self", and putting that property value of sehenswuerdigkeit in another property.\
Also, what is the expected behavior, 'sehenswuerdigkeit' is not a target, and I'm not sure what you mean by 'browsing context' in your request.
There are only a few values that are valid for the target attribute:
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named frame
Every solution I've seen so far for opening a new browser window uses the target property in to set it to "_blank". This is frustrating because in some browsers it only opens a new tab AND combine that with the auto-resizing behvaiour at http://www.facebook.com/connect/prompt_feed.php?&message=test, it basically mangles my browser whenever I try updating my status from my site.
How can I be sure to open a new window when a user clicks on a link?
Thanks!
Trindaz on Fedang
Popups are windows, they just have some features disables. You can make a popup act like a regular window by enabling these features. For example, if you open a popup with
window.open('url', 'name', 'width=500, height=500, status=1, toolbar=1, location=1, menubar=1, resizable=1');
the window will have a toolbar, a URL bar, a status bar, menus, and it will be resizable. It will the same as any other window.
Keep in mind, however, that many browsers block window.open() under some conditions, and some of them will open new tabs if you specify a lot of features. Some are weird about it too; Chrome, for example, uses scroll bars on popups by default, but if you specifically tell it to use scroll bars in a popup (using scrollbars=1), it will open in a tab instead.
So basically there is no way to be completely sure that your page will always open in a new window, because browsers all handle this stuff differently, users can change settings too. The code above is probably your best bet if you have to have a new window, but you might want to look into other options.
window.open(URL,name,specs,replace)
function newwindow()
{
myWindow=window.open('','','width=300,height=300');
myWindow.document.write("<p>This should open in a popup</p>");
myWindow.focus();
}
There is a legitimate reason for using Target=_blank that everybody has completely overlooked, and that is when a website is written as a BOOK with chapters/pages and the Table of Contents must remain intact without using the BACK button to reload the previous page (Table of Contents). This way all a surfer needs to do is close the Target Page when finished reading and they will be back to the Table of Contents.
Lucky for us that HTML5 has reinstated the Target="_blank" code, but unfortunately the "Block Popups" must be unchecked for it to work.