简体   繁体   中英

Page reload on browser back button - java script

I have a problem on my online platform. If a user logs in the member area, I hide unnecessary menue items via access-list. It works pretty fine, but when the user, uses browser back button once he is logged in and last page is one of the hide one it generates an error because the user has no access to this page when he logged in.

So I need a way to perform a simple page reload on the login landing page if the browser back is pressed. Or the browser Back button is disabled as a whole on that specific page.


Im sorry I have no code to share, I`m working on a joomla portal and after the LogIn Module redirects me to the login landing-page I just have the possibility to place a script in the header or body of the landing page that does the asked action.

Try this:

<script>    
history.pushState(null, null, document.URL);
   window.addEventListener('popstate', function () {
   history.pushState(null, null, document.URL);
   location.reload();
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM