1
How to use the same footer, side menu and header on all pages of my site? For header and footer, I tried the following:
<html>
<head>
<script src="jquery-3.3.1.min.js"></script>
<script>
$(function() {
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
<h1>conteúdo</h1>
<div id="footer"></div>
</body>
</html>
but it won’t; only the content appears. The header/footer.html and jquery files are in the same folder, all with correct names and extensions. What am I doing wrong?
You are doing this on server or local machine?
– Sam
@Leocaracciolo It is that the method does not work in Chrome via FILE protocol. In Firefox, for example, it works.
– Sam
really, I tried it here on Mozilla and it worked. Thanks!!! , but how to make it work on Chrome too?
– Rafaela Lopes
@dvd, tonces is local
– user60252
The problem is that . load() for local files is blocked by Chrome for security reasons. It appears that there is a solution in https://stackoverflow.com/questions/245926/jquery-load-method-not-working-in-chrome
– user60252
http://www.chrome-allow-file-access-from-file.com/
– user60252