Using php, for example, would be adding this into index.php
:
<?php include("footer.php"); ?>
And in adding the html code in footer.php
.
But is it possible do the same only with html without using php or iframes?
Using php, for example, would be adding this into index.php
:
<?php include("footer.php"); ?>
And in adding the html code in footer.php
.
But is it possible do the same only with html without using php or iframes?
I think that in pure html, the only way is using iframe, sorry!
You could try to use localStorage : https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
The Web Storage API provides mechanisms by which browsers can store key/value pairs, in a much more intuitive fashion than using cookies.
an example of the idea (obviously SO doesn't allow this in snippets it can be tested/copied from here https://codepen.io/gc-nomade/pen/oGorNw )
window.onload = function() {
var loaded = localStorage.getItem("header");
if (loaded) {// if already set, load it from visitor
var header = localStorage.getItem("header");
var aside = localStorage.getItem("aside");
var footer = localStorage.getItem("footer");
document.getElementById("headers").innerHTML = header;
document.getElementById("aside").innerHTML = aside;
document.getElementById("footer").innerHTML = footer;
} else {// if first visit, load and store basic content once
var top = "<h1>hello</h1>";
var side = '<ul><li><a href="#">link</a>';
var bottom = "<p>My footer loaded via local storage </p>";
localStorage.setItem("header", top);
localStorage.setItem("aside", side);
localStorage.setItem("footer", bottom);
}
};
body {
margin: 0;
display: flex;
flex-flow: column;
height: 100vh;
background: crimson;
}
main {
flex: 1;
display: flex;
box-shadow: 2px;
}
aside {
width: 200px;
border: solid 2px;
background: tomato;
}
footer,
header {
background: lightblue;
box-shadow: 0 0 0 2px;
text-align: center;
}
aside img {
max-width: 50%;
display: block;
margin: 5vh auto;
}
<header id="headers"></header>
<main>
<aside id="aside"></aside>
<section> page content</section>
</main>
<footer id="footer"></footer>