JSFiddle - React, Tailwind, and code Playground

HTML

<html>

<head>
    <title>
        Onclick javascript to make browser go
        back to previous page?
    </title>
</head>

<body onload="myFunction()">
<button onClick="showImage()">Button</button>
<div id="first" style="height:200px; width:200px; display:none;">
    <h1>
    test
    </h1>
    <img src="PP.jpg"/>
</div>

<script>
    const showImage = () => {
    		sessionStorage.setItem('showImage', 'true');
        document.getElementById("first").style.display ='block';
    }
    
    function myFunction() {
      if (sessionStorage.getItem('showImage') === 'true') {
        document.getElementById("first").style.display ='block';
        localStorage.removeItem('showImage');
      }
    }
    
    
</script>

    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>
        Onclick javascript to make browser
        go back to previous page?
    </b>

    <h2>Page 1</h2>

    <p>
        Click on the link to get
        to the second page.
    </p>

    <a href="Page2.html">Go to Page 2</a>
</body>

</html>