Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Make browser back button show login page without error div

I have a Login jsp that takes user email and sends it to servlet. If the email is not in database, the servlet redirects back to Login.jsp with an attribute "error". In the Login.jsp header I already have a scriplet that checks for this attribute and if it is set, it makes error msg div "display: block", else it makes "display:none". In this error msg I have a button with javascript to redirect to register page.

My Problem is: If I press browser back button when in register page, it shows login page still with the error message. I want it to instead show login page without error msg div.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The thing is that when you press back the browser doesn't always reload the page, that's the reason of the logging still showing the error, so what you need is to force the page to reload. Here you have a link to the solution that im giving you, hope it works How to force reloading a page when using browser back button?

Edit:

Answering to your comment, yes, it should be placed in the js file, something like this should do the trick

var perfEntries = performance.getEntriesByType("navigation");  

(function(){
    if (perfEntries[0].type === "back_forward") {
        location.reload(true);
    }
}());

This is a function that doesn't require to be called, the function calls itself when the JS file is loaded

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!