WordPress opens link in same window despite target="_blank" - html

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.

Related

Clicking link with target _blank makes browser close new tab immediatly

Clicking on a link to our webpage using
Link
opens a new tab and closes it immediatly. This happens on all browsers apparently. Deactivating adblock and alike does not change anything.
Using the url without target="_blank" or right click -> open in new Tab however works fine.
The web page is an angular project and does not use any sort of trackers. Furthermore this behavior started only recently, so I assume it's due to some change in the page.
Any hint why this happens or where to start debugging this?
Found it.
I had a line window.close(); due to a workaround for a popup for facebook login, implementing this:
Facebook Login not working in PWA app if app is in stand alone state

Safari confuses browsing context when using 'download' attribute on anchors

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?

Flicker in IE11 on page load, but not in developer mode

I'm getting flicker on page load or postback of a coloured page body in IE11, on externally hosted site (ie. not from local disk).
The odd thing is it goes away if I either:
Open F12 developer tools
Add the site to trusted sites
Add the site to restricted sites
I've got a VM with IE9 which works fine. Works fine on Chrome.
I obviously cannot use any of the above as a solution!!!
This sample code has one link that switches between two pages. I've removed everything else, javascript, css files etc.
--- page1.html ---
<html>
<body style="background-color:#000000">
Page 2
</body>
</html>
And then an identical page2.html that refs back to page 1.
Clicking on the link flickers the background from white to black each time, unless using any of the "fixes" above!
I have found another way to temporary fix this bug by adding an empty event handler through JS.
link such .js file to you html
fix_ie.js:
if(window.addEventListener){
window.addEventListener('beforeunload', function(){});
}

Desktop webpage

I have a webpage which has links to documents (MS Word .doc files). If you view this webpage on IE8 directly, and click on one of these document links, it opens up a new IE8 window/tab and displays the document directly in IE8 with a limited MS Word tool bar which is perfect.
If I then change the desktop background to the webpage, if the user then clicks on the same document links above, the documents open directly is MS Word. Why is this happening? I need it to continue to open directly in a new IE8 window.
This is what the HTML link looks like:
Document 1
This bit of HTML works perfectly in IE8 directly, but when the web page which contains this link is used via right click desktop in XP > Properties > Desktop > Customize Desktop > Web where the webpage url is added to show the webpage on the desktop, if I then click on the above document1.doc link, it opens in MS Word instead of IE8.
You could indeed try to set the target to _blank, but if this doesn't work, I think i have a solution.
Create a new html page in the same directory as the one you're running from your desktop.
This should be the content:
//keep in mind: the javascript code ain't mine, but it works ;).
<html>
<head>
<script type="text/javascript">
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}
document.location = getQuerystring('redirect');
</script>
</head>
<body>
you're being redirected
</body>
</html>
On it's own, this file doesn't do anything. But if you change the links on your desktop HTML file to
NAME_OF_NEW_FILE_THAT_YOU_JUST_MADE.html?redirect=LINK_THAT_YOU_HAD_BEFORE
it's all a little sketchy, but it works. It will open in your browser, because it's HTML. And it will open your file as well, thanks to JS
The default behaviour when opening MS Word files in IE8 is to open them in a new tab with the limited toolbar. When you are using the same page as a background on Active Desktop you are no longer using IE8, and therefore it will open directly in MS Word.
So, I dont think there is a way to "embed" the document as a background or to trigger it to open IE8.
target = "_blank" would open in a new tab, which I don't think Active Desktop supports. Try target = "_self"

IE opens a new window for a link, FF doesn't

Very strange, I have a list of products. When a user clicks on an the image it opens up a new IE window.
Firefox doesn't do this.
What could be the reason for this?
the urls are:
http://website.example.com
and clicking on the image goes to (which is hosted on another server):
http://store.website.example.com
Could this be some internal security measure or ?
Note: I don't have target=_blank and I even tried addign target=_self but no change.
Update
It turns out some javascript function was searching for certain urls and modifying its behaviour! thanks.
A new window is generally prompted by a target attribute on the A tag:
linktext
FF can supress/override this behaviour in it's preferences.
<a href="http://store.website.example.com" target="_blank">