JSFiddle - React, Tailwind, and code Playground

by Joe

HTML

<div id="welcome">
It's your first time here.
</div>
<button onclick="reloadP()">
Click
</button>

JavaScript

function myFunction() {
	document.getElementById("welcome").textContent = "Welcome back!";
}

window.onload = function() {
    var reloading = sessionStorage.getItem("reloading");
    if (reloading) {
        sessionStorage.removeItem("reloading");
        myFunction();
    }
}

function reloadP() {
    sessionStorage.setItem("reloading", "true");
    document.location.reload();
}