Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 529 Bytes

how_do_you_capture_browser_back_button.md

File metadata and controls

17 lines (10 loc) · 529 Bytes

How do you capture browser back button?

You can capture the browser's back button by listening to the popstate event. This event is triggered when the active history entry changes.

Example:

window.addEventListener('popstate', function(event) {
  console.log('Back button was pressed');
});

Tags: intermediate, JavaScript, Browser Events