Gonzalo Gonzalo - 6 months ago 9
Javascript Question

How to reload the page after logging out <javascript>

I am building a webpage and I'm having issues refreshing the page after I log out.
What I do when I log out is basically hiding one div and then show the "maindiv" which is basically the main page where you log in. Something like this:

function myfunction(){

$("#seconddiv").hide();

$("#maindiv").show();

}


This works perfectly fine in order to take me to the main page but when I try to log in again, it won't work. Thanks in advance if you can give me some advice.

Answer

You can try this:

window.location.reload()