remove target="_blank" for PWA users

pull/2/head
Aevann1 2022-11-21 19:41:40 +02:00
parent f272989735
commit 3f0966bf03
2 changed files with 16 additions and 0 deletions

View File

@ -266,6 +266,9 @@ function bs_trigger(e) {
i.addEventListener('keydown', speed_carot_navigate, false);
});
}
if (typeof link_trigger === "function")
link_trigger(e);
}
var bsTriggerOnReady = function() {

View File

@ -11,6 +11,19 @@
{% macro javascript() %}
<script defer src="{{'js/vendor/bootstrap.js' | asset}}"></script>
<script defer src="{{'js/core.js' | asset}}"></script>
<script>
if (window.matchMedia('(display-mode: standalone)')['matches']) { // if PWA
function link_trigger(e) {
const links = e.querySelectorAll('a[target="_blank"]'); // get links with target="_blank"
for (const link of links) { // loop on them
link.removeAttribute("target");
}
}
document.addEventListener('DOMContentLoaded', link_trigger(document));
}
</script>
{% endmacro %}
{% macro page_meta(title=none) %}