If you want to use iframes, consider searching for JQuery plugins that support iframe functionality like . Alternatively, you can utilize a JavaScript template engine such as https://github.com/BorisMoore/jquery-tmpl
Update 1:
You have the option to include static elements of your page, like header and footer, in templates and then render them on specific tags within the body upon page load.
Another approach is saving the HTML code of the header into a variable in a JavaScript file. Then, set the inner HTML of the header during onload.
Page 1
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="layout.js" ></script>
</head>
<body>
<div id="content">page 1</div>
</body>
</html>
Page 2
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="layout.js" ></script>
</head>
<body>
<div id="content">
page 2
</div>
</body>
</html>
layout.js
function mylayout(){
var _body = document.getElementsByTagName('body')[0];
var s = '<li>text</li>';
var header_div = document.createElement('div');
header_div.innerHTML = "<p> this is <b style=\"color: blue\"> header</b><br><a href=\"page1.htm\">page1</a> <a href=\"page2.htm\">page2</a></p>";
var footer_div = document.createElement('div');
footer_div.innerHTML = "<p> this is <b style=\"color: red\"> footer</b></p>";
if (_body.firstChild){
_body.insertBefore(header_div, _body.firstChild);
} else {
_body.appendChild(header_div);
}
_body.appendChild(footer_div);
}
window.onload = function() {
mylayout();
};