is it possible, or how could I make it so, I can include my topbar file into my page, I'd prefer it not to be with php since I am not hooked up with localhost yet.
Thanks for all help in advance!
HTML5 now allows you to include html files like you can already include a css file via an import. However, this would only be helpful for during your development stages and not for the final production version since the feature currently is only available in Chrome and will take time for the other browsers to adopt: http://www.html5rocks.com/en/tutorials/webcomponents/imports/
If you don't want to use PHP nor any other server-side scripting language,
you can use either <iframe> or <frameset> tags, which are deprecated, or perform an AJAX request using Javascript that embeds your HTML page dynamically. Second approach will work only if the page you're trying to attach is located within the same domain due to XSS protection in modern browsers.
It's more of a server thing, so to speak, so you would have to rely on the server more for this. Because, you cannot simply do this using static script, like HTML. There's no "built-in function" that can do this, it's not HTML's thing.
I mean, server will offer you more than one option, for example:
You can:
Use SSI (Server-side Includes) if server supports it.
Use PHP or ASP includes.
If you mean "header" by saying "topbar", I think it's not a good idea to use iframes.
Use <!--#include file="footer_text.html" -->
inside html page.
Plz, check below url for details.
https://www.lifewire.com/include-html-file-in-another-3469529
you can fetch the .html file and put it into your html using javascript:
$(document).ready(function() {
// Load the external header HTML into the page
fetch('/html_templates/template.html')
.then(response => response.text())
.then(html => {
// set contents of template to specific div
$('#container_id').html(html);
})
.catch(error => console.error('Error loading template:', error));
console.log("DOMContentLoaded");
});
index.html
<html>
<body>
<script src="js/jquery-3.7.1.min.js"></script> </script>
<div id="container_id"></div>
</body>
</html>
you need to download jquery (jquery-3.7.1.min.js) and put it into folder /js