A little JavaScript will do.
Org file:
#+HTML_HEAD: <script type="text/javascript" src="post.js"></script>
I used the Bash shell keyword ~time~ to obtain time consumed by the
building process. I added the option ~-rtlib=compiler-rt~ to
~LDFLAGS~, since Clang would complain ~undefined reference to
`__muloti4'~ without it (see [[clang-bug:16404][bug]]). Clang 5.0 also provides a linker
called ~lld~ and claims that it is faster than the built-in linker.
As per [[using-lld][instruction]], I added ~-fuse-ld=lld~ to ~LDFLAGS~ as a third
group.
#+LINK: clang-bug https://bugs.llvm.org/show_bug.cgi?id=%s
#+LINK: using-lld https://lld.llvm.org/#using-lld
JavaScript file named "post.js":
document.addEventListener("DOMContentLoaded", () => {
const anchors = document.getElementsByTagName("a");
for (const anchor of anchors) {
anchor.target = "_blank";
}
});
Put the JavaScript file in the same folder as the exported HTML file. Then you are fine.
If you want to support older browsers, you can use the following code instead.
window.onload = function() {
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
anchors[i].target = "_blank";
}
};
In addition, you probably do not want to open an internal link (like this link) in a new tab. Then you can use the following code as I did on my own site.
window.onload = function() {
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
if (anchor.hostname !== window.location.hostname
|| anchor.pathname !== window.location.pathname) {
anchor.target = "_blank";
}
}
};
target="_blank"
to the<a ... >
tag generated for links. Source: w3schools.com/tags/att_a_target.asp. Or try this out: orgmode.org/manual/… – Kaushal Modi Jul 29 '15 at 10:40