Skip to content

Commit e085c40

Browse files
committed
fix opening anchor tags on same site
1 parent 0953b6d commit e085c40

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

js/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ document.addEventListener('DOMContentLoaded', () => {
5151
});
5252
});
5353

54-
// open all links in seperate tab
54+
// Open all links in a separate tab, excluding anchor links on the same page
5555
var links = document.links;
5656
for (var i = 0; i < links.length; i++) {
57-
links[i].target = "_blank";
57+
var href = links[i].getAttribute("href");
58+
// Check if the href starts with "#" or is an anchor to the current page
59+
if (href && !href.startsWith("#") && !href.startsWith(window.location.pathname + "#")) {
60+
links[i].target = "_blank";
61+
}
5862
}
5963
});
6064

robotics_conferences_analyzed.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<div id="navbarBasicExample" class="navbar-menu">
5353
<div class="navbar-end">
5454
<a class="navbar-item" style="text-align:right" href='/'>
55-
Main Page
55+
Home Page
5656
</a>
5757

5858
</div>
@@ -95,7 +95,7 @@ <h2 class="title is-4 anchor" style="margin-top: 1.5em;" id="{{conference.name}}
9595
<div class="column is-8">
9696
<div class="content">
9797
<p>
98-
Visit the main page of <a href="https://oliver.hausdoerfer.de/">Oliver Hausdörfer</a>.
98+
Visit my <a href="https://oliver.hausdoerfer.de/">home page</a>.
9999
</p>
100100
</div>
101101
</div>

0 commit comments

Comments
 (0)