Safari (v11.0.3 for example) now supports download attribute on anchor elements, BUT, using them will break other links on the page which use the _blank target browsing context.
Example:
<html>
<body>
<a href="/file_to_download" download>Download</a>
<br/>
View
</body>
</html>
Click on "View", browser opens page in new window.
Click on "Download", browser downloads the file requested.
Click on "View" again, browser downloads the page rather then open a new window.
Change the target attribute of the View anchor, and there are no problems (...except you'll not open a new window, of course.)
Other browsers handle this as expected, downloading one, viewing the other.
Am I missing something?
Related
On my page http://verein-iks.eu/dev/ I have a Facebook button on the top-right. If I click the button, I get forwarded to a Facebook page. However, the link is opened in the same window. I want it to be opened in a new window/tab. Hence, I use target='_blank' in the HTML code. Still, the link gets opened in the same window! Why?
When checking the source code (Ctrl+U in Firefox and Chrome) of the page, you can see on line 166 that the target is indeed set to target="_blank". Strangely, when I inspect the element (in Chrome via Ctrl+Shift+I), the target="_blank" property seems to have disappeared.
If you have wp accessibility plugin activated in your wordpress installation there is a checkbox in wp accessibility settings, under Miscellaneous Accessibility Settings which called Remove target attribute from links. Uncheck it and everything will by fine :)
In the footer of your DOM, there is a <script> that is removing the target attribute from all links...
<script type="text/javascript">
//<![CDATA[
(function( $ ) { 'use strict';
$('a').removeAttr('target'); //This will remove the target attribute from all links on page load
$('input,a,select,textarea,button').removeAttr('tabindex');
}(jQuery));
//]]>
</script>
The reason you see the attribute when viewing the source is due to the fact that the source is what was received from the server. Inspect Element is a live view of what happens with the DOM, so it renders the result of the executed JS.
I have a jsp page. In that I have multiple links. In http mode, if any link clicked then it opens the target page in the same window.
but in https mode, if any link clicked then it opens the target page in a new window. How to open the target page in the same window when in https mode.
I believe html target attribute has its own options to open link..
<a target="_blank|_self|_parent|_top|framename">
<a herf="" target="_parent">LINK</a>
should open link in the same parent window instead of popping up new window.
In my link, I have target="_blank" attribute, and it works in Chrome, Firefox, Opera, and of course, Safari and opens the link a new TAB. But When I click on it, in IE9 (and IE8) it opens a new window instead of being opened in a new tab. What should I do?
HTML and JavaScript provide no means to say if a new "window" should be a full window, or a tab, or whatever you want to call the Mobile Safari multiple views interface.
So you live with it.
You can see in this question that the target="_blank" is correct, but the way the browser handles this case is up to his settings.
You need to change IE8/9 settings to open that kind of target in a new tab. There's nothing you can do :|
This is configured browser side and theres nothing you can do about it in your html I'm afraid. Its just an option that a user sets in their browsers preferences.
You need to use the target="_blank" attribute to make links open in a new window or tab. Where the link actually opens is up to the browser settings. So if you have Tools > Internet Options > Tabbed Browsing Settings > "Always open pop-ups in new tabs" selected, a target="_blank" link will open in a new tab. Note that this type of link will open in a new window by default on most browsers.
Unchecking Protected Mode in IE9 resolved my problem.
Windows Internet Explorer 8 and later. When Protected Mode is enabled and a webpage contains an anchor link with a named target, Windows Internet Explorer opens the target of the link in a new window when the target has a different integrity level than the webpage containing the link.
Source: target attribute in IE
<a ... target="_blank">...</a>
This kind of link only opens a new tab,but some websites will open a new browser instance,what's the trick?
In Firefox, opening a link in a new tab or window is controlled by the browser's setting. There are ways to manipulate it such as:
window.open("", "test", "height=300,width=300,modal=yes,alwaysRaised=yes")
If both links are the same in all these websites, so there is a javascript window.open get called in the links which open new browser.
It is based on the browser settings, that why I said that if all links looks the same and some act different than other so there is some javascript work.
By the way,
If you set the target attribute to
"_blank", the link will open in a new
browser window or a new tab.
Based on the browser settings
This is a line for a hyperlink in HTML:
Starfall
Thus, if I click on "Starfall" my browser - I am using FireFox - will take me to that new page and the contents of my window will change. I wonder, how can I do this in HTML so that the new page is opened in a new window instead of changing the previous one? Is there such a way in HTML?
And if yes, is there a way to open the requested page in another tab (not another window) of my browser?
Starfall
Whether it opens in a tab or another window though is up to how a user has configured her browser.
Simplest way is to add a target tag.
Starfall
Use a different value for the target attribute for each link if you want them to open in different tabs, the same value for the target attribute if you want them to replace the other ones.
use target="_blank"
<a target='_blank' href="http://www.starfall.com/">Starfall</a>
You should be able to add
target="_blank"
like
Starfall
The target attribute is your best way of doing this.
<a href="http://www.starfall.com" target="_blank">
will open it in a new tab or window. As for which, it depends on the users settings.
<a href="http://www.starfall.com" target="_self">
is default. It makes the page open in the same tab (or iframe, if that's what you're dealing with).
The next two are only good if you're dealing with an iframe.
<a href="http://www.starfall.com" target="_parent">
will open the link in the iframe that the iframe that had the link was in.
<a href="http://www.starfall.com" target="_top">
will open the link in the tab, no matter how many iframes it has to go through.
the target = _blank is will open in new tab or windows based on browser setting.
To force a new window use javascript onclick all three parts are needed. url, a name, and window width and height size or it will just open in a new tab.
<a onclick="window.open('http://www.starfall.com/','name','width=600,height=400')">Starfall</a>
You can also accomplish this by adding the following to your page's header:
<base target="_blank">
This will make ALL links on your page open in a new tab
Since web is evolving quickly, some things changes with time. For security issues, you might want to use the rel="noopener" attribute in conjuncture with your target="_blank".
Like stated in Google Dev Documentation, the other page can access your window object with the window.opener property. Your external link should looks like this now:
Starfall
below example with target="_blank" works for Safari and Mozilla
<a href="http://www.starfall.com" `target="_blank"`>
Using target="new"worked for Chrome
<a href="http://www.starfall.com" `target="new"`>