6
0
Fork 0

Flutizität erhöhen (link prefetch=

master
Dirk Heilig 2024-01-09 13:05:30 +01:00
parent d522878755
commit 704c9c0cbf
3 changed files with 19 additions and 10 deletions

View File

@ -78,6 +78,6 @@
<link rel="stylesheet" href="{{ "css/style.css" | relURL }}" /> <link rel="stylesheet" href="{{ "css/style.css" | relURL }}" />
<link rel="shortcut icon" href="{{ "images/favicon.ico" | relURL }}" type="image/x-icon" /> <link rel="shortcut icon" href="{{ "images/favicon.ico" | relURL }}" type="image/x-icon" />
<script src="/js/jquery-3.7.1.min.js"></script> <script src="/js/jquery-3.7.1.min.js"></script>
<script src="/js/layout.js"></script> <script src="/js/href_handling.js.js"></script>
<script src="/js/door-status.js"></script> <script src="/js/door-status.js"></script>
<script src="/js/calendar.js"></script> <script src="/js/calendar.js"></script>

View File

@ -0,0 +1,18 @@
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll('a').forEach(function(element) {
const myhost = window.location.hostname;
const linkhost=new URL(element.href).hostname;
if(myhost === linkhost) {
let prefetchUrl=new URL(element.href).toString()
// lest make a prefetch tag for this url
let link = document.createElement('link');
link.setAttribute('rel', 'prefetch');
link.setAttribute('href', prefetchUrl);
link.setAttribute('as', 'document');
document.head.appendChild(link);
}else {
element.setAttribute("target", "_blank");
}
})
});

View File

@ -1,9 +0,0 @@
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll('a[href^="http"]').forEach(function(element) {
const myhost = window.location.hostname;
const linkhost=new URL(element.href).hostname;
if(myhost === linkhost) return;
element.setAttribute("target","_blank");
})
});