Miami Skyline

Colada & Code

Window Navigator

by: Raul Martinez

Recently, I was tasked with reseting all of the input values on a form. Here is the situation.

There is a form on one page, and once the form is submitted the user is navigated to a "Thank you" page. If the user were to click the 'Back' button on their browser. All of their information was still there, but the goal was to have a fresh form with no inputs filled out.

After doing some research I came across Perfomance Navigation on the Mozilla Web Docs. This allowed me to implement a solution onto the page to check if the user had clicked the 'Back' button.

if (window.performance.navigation.type === 2) {