javascript refresh page once code example

Example 1: javascript reload page

location.reload();

Example 2: javascript reload page one time

window.onload = function() {
	if(!window.location.hash) {
		window.location = window.location + '#loaded';
		window.location.reload();
	}
}

Example 3: meta refresh only once

document.getElementById('iframeID').contentWindow.location.reload();

Example 4: javascript refresh page automatically

<meta http-equiv="refresh" content="30"/>

Example 5: refresh page and run function after javascript

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

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

Tags:

Css Example