diff --git a/.changes/core-base-links-target.md b/.changes/core-base-links-target.md new file mode 100644 index 000000000..231383077 --- /dev/null +++ b/.changes/core-base-links-target.md @@ -0,0 +1,5 @@ +--- +'tauri': 'minor:enhance' +--- + +Open links externally when `` exists diff --git a/core/tauri/scripts/core.js b/core/tauri/scripts/core.js index 0ac489544..ad2196c17 100644 --- a/core/tauri/scripts/core.js +++ b/core/tauri/scripts/core.js @@ -91,13 +91,14 @@ document.querySelector('body').addEventListener( 'click', function (e) { - var target = e.target + let target = e.target + const baseTarget = document.querySelector('head base')?.target while (target != null) { if (target.matches('a')) { if ( target.href && (['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) && - target.target === '_blank' + (target.target === '_blank' || (!target.target && baseTarget === "_blank")) ) { window.__TAURI_INVOKE__('tauri', { __tauriModule: 'Shell',