Home > Software engineering >  HTML automatically go back to previous page
HTML automatically go back to previous page

Time:09-30

How do I make the html go back to previous page? I do not want to do it via a button, just that when this html gets loaded, it should automatically go back to previous page.

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv='refresh' content='0; URL='>
      </head>
</html>

CodePudding user response:

You have two options. JavaScript or HTML Meta Tags.

A JavaScript example would be

window.addEventListener('DOMContentLoaded', function() { 
   history.go(-1); 
});

Or using HTML Meta Tags like this:

<meta http-equiv="refresh" content="2;url=http://example.net">

Hope it helps! Be aware that this behaviour is, generally, not expected by the user, and could cause confusion

CodePudding user response:

You may wanna use the history.back() method that looks up at your history and send you back to the last visited website.

  •  Tags:  
  • html
  • Related