← All examples

JavaScript Navigation whatsapp.com

WhatsApp Web: scroll-to-top button

Adds a floating button that scrolls the currently open chat history to the very top in one click.

Code to copy

// Add a floating button to scroll the open chat to the very top
(function () {
  if (document.getElementById('jz-wa-scroll-top')) return;
  const btn = document.createElement('button');
  btn.id = 'jz-wa-scroll-top';
  btn.textContent = '↑';
  btn.style.cssText = 'position:fixed;right:20px;bottom:80px;z-index:9999;width:42px;height:42px;border-radius:50%;border:none;background:#25d366;color:#fff;font-size:20px;cursor:pointer;box-shadow:0 3px 10px rgba(0,0,0,0.25);';
  btn.addEventListener('click', function () {
    const pane = document.querySelector('#main [data-testid="conversation-panel-messages"], #main div[role="application"]');
    if (pane) pane.scrollTop = 0;
  });
  document.body.appendChild(btn);
})();

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases