Execute Javascript code on browser back button

Author - Kritika Sood

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

jQuery(document).ready(function($)
{
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

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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