diff options
author | Thomas Lange <code@nerdmind.de> | 2018-05-15 01:39:38 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2018-05-15 01:39:38 +0200 |
commit | 0ca5f4750730fd71c4fd230f0024c55590dac0cf (patch) | |
tree | f98b00cb8be0b00875e475dd3d368c992ba8ebf1 | |
parent | e8357d31e7cb3629ebde78653e3345fd7997df41 (diff) | |
download | blog-0ca5f4750730fd71c4fd230f0024c55590dac0cf.tar.gz blog-0ca5f4750730fd71c4fd230f0024c55590dac0cf.tar.xz blog-0ca5f4750730fd71c4fd230f0024c55590dac0cf.zip |
Fix javascript problem that causes unintended behavior
If you browse in a browser tab through some websites and want to go back to the previous page, post or user, you can either click the history back button, press the corresponding key on your mouse or even press <alt>+<arrow-left> on your keyboard. But if you only press <arrow-left> on a page, post or user, the callback function of the "keyup" event will change the location in the desired direction on the blog if there is a previous page, post or user, and if neither <ctrl> nor <shift> is pressed. This is a functionality of the javascript from the template and not a functionality of your browser.
Pressing <alt>+<arrow-left> IS a functionality of the browser and should not conflict with the behavior when <arrow-left> is pressed alone. This commit fixes this problem by adding the condition that <alt> should not be pressed either.
-rw-r--r-- | template/admin/rsrc/main.js | 2 | ||||
-rw-r--r-- | template/standard/rsrc/main.js | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/template/admin/rsrc/main.js b/template/admin/rsrc/main.js index 1870ced..46880f2 100644 --- a/template/admin/rsrc/main.js +++ b/template/admin/rsrc/main.js @@ -8,7 +8,7 @@ const next = document.getElementById("next-site"); // Handle arrow keys and change the location to the desired direction //============================================================================== document.addEventListener("keyup", function(e) { - if(!e.ctrlKey && !e.shiftKey) { + if(!e.ctrlKey && !e.shiftKey && !e.altKey) { (e.keyCode === 37 && prev) && (window.location.href = prev.getAttribute("href")); (e.keyCode === 39 && next) && (window.location.href = next.getAttribute("href")); } diff --git a/template/standard/rsrc/main.js b/template/standard/rsrc/main.js index 6d088e3..f73d061 100644 --- a/template/standard/rsrc/main.js +++ b/template/standard/rsrc/main.js @@ -8,7 +8,7 @@ const next = document.getElementById("next-site"); // Handle arrow keys and change the location to the desired direction //============================================================================== document.addEventListener("keyup", function(e) { - if(!e.ctrlKey && !e.shiftKey) { + if(!e.ctrlKey && !e.shiftKey && !e.altKey) { (e.keyCode === 37 && prev) && (window.location.href = prev.getAttribute("href")); (e.keyCode === 39 && next) && (window.location.href = next.getAttribute("href")); } |