Use of target="_blank" link attributes in XHTML 1.0 strict content
Submitted by jdeathe on Thu, 01/08/2015 - 04:50
Add the following JavaScript to a Document Editor using the snippet feature if targeting a single Document Editor or include it globally if it is required site wide:
<script type="text/javascript">
/*global window, setTimeout */
(function (window, linkClass) {
"use strict";
var document = window.document,
i = 0,
lim = 0,
link = null,
linkClassName = linkClass || 'external_link',
links = null;
function run() {
if (document.readyState !== "complete") {
return setTimeout(run, 100);
}
links = document.getElementsByTagName('a');
lim = links.length;
for (i = 0; i < lim; i += 1) {
link = links[i];
if (link.className && link.className.indexOf(linkClassName) !== -1) {
link.target = '_blank';
}
}
}
run();
}(window, 'link-external'));
</script>
Add a link via the Document Editor and then, using the HTML view, add a className. In the above example we are using "link-external" so we need to add the following to links we want to open in a new browser window/tab:
class="link-external"
General Concept:
Jadu Product:
