Scroll page to top/bottom bookmark

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
User avatar
fstjohn
Level 5
Level 5
Posts: 534
Joined: Fri Jan 02, 2015 3:21 pm
Location: The beautiful North Georgia mountains

Scroll page to top/bottom bookmark

Post by fstjohn »

Here's a handy little javascript I found somewhere on the internet. It works in Firefox, Chrome/chromium, Brave and derivatives. Just create a new bookmark and paste the javscript into the URL field. Copy and paste the up/down arrow into the bookmark name field. Click on the bookmark to move to the top or bottom of the page. This replaces any of the several extensions that do basically the same thing.

Code: Select all

↑↓

Code: Select all

javascript:(function () {var paBody = document.body, paHtml = document.documentElement, paMaxY = Math.max(paBody.scrollHeight, paBody.offsetHeight, paHtml.clientHeight, paHtml.scrollHeight, paHtml.offsetHeight) - window.innerHeight, paBreakPoint = 300; if(window.scrollY > paBreakPoint || paBreakPoint >= paMaxY && window.scrollY != 0) window.scroll({top: 0, behavior: 'smooth'}); else window.scroll({top: paMaxY, behavior: 'smooth'});})();
Post Reply

Return to “Tutorials”