Skip to content

Commit

Permalink
Automatically open links to new tab (#743)
Browse files Browse the repository at this point in the history
* Add JS code to open links in new tab

* Add `open-new-tab.html` to `_output.yml`
  • Loading branch information
howardbaik authored Apr 12, 2024
1 parent 700732b commit bac0bdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _output.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ bookdown::gitbook:
css: assets/style.css
includes:
before_body: assets/big-image.html
after_body: assets/footer.html
highlight: tango
after_body: [assets/footer.html, assets/open-new-tab.html]
highlight: tango
config:
toc:
collapse: section
Expand Down
9 changes: 9 additions & 0 deletions assets/open-new-tab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
var links = document.getElementsByTagName('a');
var len = links.length;

for(var i=0; i<len; i++)
{
links[i].target = "_blank";
}
</script>

0 comments on commit bac0bdb

Please sign in to comment.