Execute Javascript code on browser back button

| By Webner

Here is sample code to trap browser back button and execute Javascript code on this event:

if (window.history && window.history.pushState)
$(window).on('popstate', function() {//when back is clicked popstate event executes
//code here will execute on back click

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Web development or any other software development assistance please contact us at webdevelopment@webners.com

Leave a Reply

Your email address will not be published. Required fields are marked *